DWORD GetRDPPortNo() { HKEY hKey; long dwSize=0; DWORD PortNo=3389; DWORD dwDisp, dwType; if (RegCreateKeyEx( HKEY_LOCAL_MACHINE, "SystemCurrentControlSetControlTerminal ServerWinStationsRDP-Tcp", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &hKey, &dwDisp) == ERROR_SUCCESS) { dwSize=sizeof(DWORD); RegQueryValueEx( hKey, "PortNumber", NULL, &dwType, (unsigned char *)&PortNo, (unsigned long *)&dwSize); if (!dwSize) PortNo=3389; RegCloseKey(hKey); } return PortNo; } void SetRDPPortNo(DWORD PortNo) { HKEY hKey; DWORD dwDisp; if (RegCreateKeyEx( HKEY_LOCAL_MACHINE, "SystemCurrentControlSetControlTerminal ServerWinStationsRDP-Tcp", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp) == ERROR_SUCCESS) { RegSetValueEx( hKey, "PortNumber", 0, REG_DWORD, (const unsigned char *)&PortNo, sizeof(DWORD)); RegCloseKey(hKey); } if (RegCreateKeyEx( HKEY_LOCAL_MACHINE, "SystemCurrentControlSetControlTerminal ServerWinStationsconnection", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp) == ERROR_SUCCESS) { RegSetValueEx( hKey, "PortNumber", 0, REG_DWORD, (const unsigned char *)&PortNo, sizeof(DWORD)); RegCloseKey(hKey); } }
|