int TestWtsApiShutdownSystem(int argc, char* argv[]) { BOOL bSuccess; HANDLE hServer; DWORD ShutdownFlag; #ifndef _WIN32 if (!GetEnvironmentVariableA("WTSAPI_LIBRARY", NULL, 0)) { printf("%s: No RDS environment detected, skipping test\n", __FUNCTION__); return 0; } #endif hServer = WTS_CURRENT_SERVER_HANDLE; ShutdownFlag = WTS_WSD_SHUTDOWN; bSuccess = WTSShutdownSystem(hServer, ShutdownFlag); if (!bSuccess) { printf("WTSShutdownSystem failed: %d\n", (int) GetLastError()); return -1; } return 0; }
// @pymethod |win32ts|WTSShutdownSystem|Issues a shutdown request to a terminal server static PyObject *PyWTSShutdownSystem(PyObject *self, PyObject *args, PyObject *kwargs) { static char *keywords[]={"Server", "ShutdownFlag", NULL}; PyObject *obh; HANDLE h; DWORD flags; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Ok:WTSShutdownSystem", keywords, &obh, // @pyparm <o PyHANDLE>|Server||Handle to a terminal server &flags)) // @pyparm int|ShutdownFlag||One of the win32ts.WTS_WSD_* values return NULL; if (!PyWinObject_AsHANDLE(obh, &h)) return NULL; if (!WTSShutdownSystem(h, flags)) return PyWin_SetAPIError("WTSShutdownSystem"); Py_INCREF(Py_None); return Py_None; }
int TestWtsApiShutdownSystem(int argc, char* argv[]) { BOOL bSuccess; HANDLE hServer; DWORD ShutdownFlag; hServer = WTS_CURRENT_SERVER_HANDLE; ShutdownFlag = WTS_WSD_SHUTDOWN; bSuccess = WTSShutdownSystem(hServer, ShutdownFlag); if (!bSuccess) { printf("WTSShutdownSystem failed: %d\n", (int) GetLastError()); //return -1; } return 0; }