///////////////////////////////////////////
// port.cpp文件
#include <cstdlib>
#include <stdio.h>
#include <windows.h>
#include <iostream>
using namespace std;
//typedef unsigned char byte;
int main()
{
HKEY hKey;
LONG lRet = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE,L"SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp",0,KEY_QUERY_VALUE, &hKey);
if(lRet != ERROR_SUCCESS)
{
printf(" failed
");
return 0;
}
else
{
printf("Terminal Server(遠程桌面)端口為:");
DWORD port,Length;
long ret1=::RegQueryValueExW(hKey, L"PortNumber", 0, 0, (unsigned char*)&port, &Length);
//cout <<hex<< port;
cout << port;
}
::RegCloseKey(hKey);
getchar();
return 0;
}