我的程序中用WTSGetActiveConsoleSessionId来获取当前系统用户的ID,处理切换用户的一些操作,使用WTSGetActiveConsoleSessionId要求#define _WIN32_WINNT 0x0501否则编译通不过,但在2000系统下,由于不支持WTSGetActiveConsoleSessionId函数,所以运行就报错,提示无法将函数定位到kernel32.dll上,现在请问各位大侠有没有办法既可以用WTSGetActiveConsoleSessionId,又在2000下不会报错
解决方案 »
- List Control 单击表头排序??请求资源!
- 请问一个打开和关闭exe文件的问题
- InstallShield里面WaitOnDialog返回-1是怎么回事?
- access的文本类型最大只有255,程序要求可以存更多的内容,怎么办?
- User breakpint called from code at 0x77FA144B我没有设制任何断点,为什么会出这个提示呢??
- 高分求助!一个RichEdit的内容可以由多人填写,但后面填写的人不能修改前面人写的内容,如何处理??
- 我以前的问题都已经结贴了,现在又有一个问题,很Easy的--30分
- 怎样使程序在拖动过程中,其中某个(或者全部)线程不停止工作
- 【求助】弹出对话框,并在上双缓冲绘图,迷惑!
- 我的DLL中Create了一个窗口,但是在DLL的ExitInstance() 函数中调用该窗口的DestroyWindow()函数时,afxMapHWND()返回的HandleMap 是NULL的断言失败为什么???
- VC6回车退出问题!!
- RTP/RTCP如何得到当前媒体流的时间位置
一下摘自msdn#include <windows.h>
#include <stdio.h>#define BUFSIZE 80int main()
{
OSVERSIONINFOEX osvi;
BOOL bOsVersionInfoEx; // Try calling GetVersionEx using the OSVERSIONINFOEX structure.
// If that fails, try using the OSVERSIONINFO structure. ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
{
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
return FALSE;
} switch (osvi.dwPlatformId)
{
// Test for the Windows NT product family.
case VER_PLATFORM_WIN32_NT: // Test for the specific product.
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
printf ("Microsoft Windows Server 2003, "); if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
printf ("Microsoft Windows XP "); if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
printf ("Microsoft Windows 2000 "); if ( osvi.dwMajorVersion <= 4 )
printf("Microsoft Windows NT "); // Test for specific product on Windows NT 4.0 SP6 and later.
if( bOsVersionInfoEx )
{
// Test for the workstation type.
if ( osvi.wProductType == VER_NT_WORKSTATION )
{
if( osvi.dwMajorVersion == 4 )
printf ( "Workstation 4.0 " );
else if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
printf ( "Home Edition " );
else printf ( "Professional " );
}
// Test for the server type.
else if ( osvi.wProductType == VER_NT_SERVER ||
osvi.wProductType == VER_NT_DOMAIN_CONTROLLER )
{
if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==2)
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
printf ( "Datacenter Edition " );
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
printf ( "Enterprise Edition " );
else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
printf ( "Web Edition " );
else printf ( "Standard Edition " );
}
else if(osvi.dwMajorVersion==5 && osvi.dwMinorVersion==0)
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
printf ( "Datacenter Server " );
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
printf ( "Advanced Server " );
else printf ( "Server " );
}
else // Windows NT 4.0
{
if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
printf ("Server 4.0, Enterprise Edition " );
else printf ( "Server 4.0 " );
}
}
}
// Test for specific product on Windows NT 4.0 SP5 and earlier
else
{
HKEY hKey;
char szProductType[BUFSIZE];
DWORD dwBufLen=BUFSIZE;
LONG lRet; lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
0, KEY_QUERY_VALUE, &hKey );
if( lRet != ERROR_SUCCESS )
return FALSE; lRet = RegQueryValueEx( hKey, "ProductType", NULL, NULL,
(LPBYTE) szProductType, &dwBufLen);
if( (lRet != ERROR_SUCCESS) || (dwBufLen > BUFSIZE) )
return FALSE; RegCloseKey( hKey ); if ( lstrcmpi( "WINNT", szProductType) == 0 )
printf( "Workstation " );
if ( lstrcmpi( "LANMANNT", szProductType) == 0 )
printf( "Server " );
if ( lstrcmpi( "SERVERNT", szProductType) == 0 )
printf( "Advanced Server " );
printf( "%d.%d ", osvi.dwMajorVersion, osvi.dwMinorVersion );
} // Display service pack (if any) and build number. if( osvi.dwMajorVersion == 4 &&
lstrcmpi( osvi.szCSDVersion, "Service Pack 6" ) == 0 )
{
HKEY hKey;
LONG lRet; // Test for SP6 versus SP6a.
lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix\\Q246009",
0, KEY_QUERY_VALUE, &hKey );
if( lRet == ERROR_SUCCESS )
printf( "Service Pack 6a (Build %d)\n",
osvi.dwBuildNumber & 0xFFFF );
else // Windows NT 4.0 prior to SP6a
{
printf( "%s (Build %d)\n",
osvi.szCSDVersion,
osvi.dwBuildNumber & 0xFFFF);
} RegCloseKey( hKey );
}
else // not Windows NT 4.0
{
printf( "%s (Build %d)\n",
osvi.szCSDVersion,
osvi.dwBuildNumber & 0xFFFF);
} break; // Test for the Windows Me/98/95.
case VER_PLATFORM_WIN32_WINDOWS: if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
{
printf ("Microsoft Windows 95 ");
if (osvi.szCSDVersion[1]=='C' || osvi.szCSDVersion[1]=='B')
printf("OSR2 " );
} if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
{
printf ("Microsoft Windows 98 ");
if ( osvi.szCSDVersion[1] == 'A' )
printf("SE " );
} if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
{
printf ("Microsoft Windows Millennium Edition\n");
}
break; case VER_PLATFORM_WIN32s: printf ("Microsoft Win32s\n");
break;
}
return TRUE;
}
然后用GetProcAddress这个函数去取WTSGetActiveConsoleSessionId这个函数的地址,如果能取到就可以call。