为什么RegisterClass会失败
各位大佬好!请教如下问题。我的程序要Skype通讯,利用Skype发的SDK中的例子做了小许改动,在win2000和winxp上都没问问题,可程序在win98上却失败了。如下:
void main(void)
{
// create window class
// create dummy/hidden window for processing messages
// run message loop thread
// do application control until exit
// exit: send QUIT message to our own window
// wait until thred terminates
// destroy main window
// destroy window class
uiGlobal_MsgID_SkypeControlAPIAttach=RegisterWindowMessage("SkypeControlAPIAttach");
uiGlobal_MsgID_SkypeControlAPIDiscover=RegisterWindowMessage("SkypeControlAPIDiscover");
if( uiGlobal_MsgID_SkypeControlAPIAttach!=0 && uiGlobal_MsgID_SkypeControlAPIDiscover!=0 )
{
printf("STEP 1\n");
if( Initialize_CreateWindowClass() )
{
printf("STEP 2\n");
if( Initialize_CreateMainWindow() )
{
printf("STEP 3\n");
hGlobal_ThreadShutdownEvent=CreateEvent( NULL, TRUE, FALSE, NULL);
if( hGlobal_ThreadShutdownEvent!=NULL )
{
printf("STEP 4\n");
if( _beginthread( &Global_InputProcessingThread, 64*1024, NULL)!=(unsigned long)-1 )
{
printf("STEP 5\n");
Global_MessageLoop();
Global_Console_CancelReadRow();
WaitForSingleObject( hGlobal_ThreadShutdownEvent, INFINITE);
}
CloseHandle(hGlobal_ThreadShutdownEvent);
}
DeInitialize_DestroyMainWindow();
}
DeInitialize_DestroyWindowClass();
}
}
}
在第一步中bool Initialize_CreateWindowClass(void)
{
unsigned char *paucUUIDString;
RPC_STATUS lUUIDResult;
bool fReturnStatus;
UUID oUUID;
fReturnStatus=false;
lUUIDResult=UuidCreate(&oUUID);
hInit_ProcessHandle=(HINSTANCE)OpenProcess( PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId());
if( hInit_ProcessHandle!=NULL && (lUUIDResult==RPC_S_OK || lUUIDResult==RPC_S_UUID_LOCAL_ONLY) )
{
Printf("open process ok\n");
if( UuidToString( &oUUID, &paucUUIDString)==RPC_S_OK )
{
Printf("uuid converse ok\n");
WNDCLASS oWindowClass;
strcpy( acInit_WindowClassName, "Skype-API-Test-");
strcat( acInit_WindowClassName, (char *)paucUUIDString);
oWindowClass.style=CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;
oWindowClass.lpfnWndProc=(WNDPROC)&SkypeAPITest_Windows_WindowProc;
oWindowClass.cbClsExtra=0;
oWindowClass.cbWndExtra=0;
oWindowClass.hInstance=hInit_ProcessHandle;
oWindowClass.hIcon=NULL;
oWindowClass.hCursor=NULL;
oWindowClass.hbrBackground=NULL;
oWindowClass.lpszMenuName=NULL;
oWindowClass.lpszClassName=acInit_WindowClassName;
if( RegisterClass(&oWindowClass)!=0 )
{
fReturnStatus=true;
}
else
{
printf("register wndclass failure!!!\n");
}
RpcStringFree(&paucUUIDString);
}
}
if( fReturnStatus==false )
CloseHandle(hInit_ProcessHandle),hInit_ProcessHandle=NULL;
return(fReturnStatus);
}
在win98上运行时输出:
step 1
open process ok
uuid converse ok
register wndClass failure
我把上面oWindowClass.hInstance=hInit_ProcessHandle;改为
oWindowClass.hInstance=NULL;后再输出就是:
step 1
open process ok
uuid converse ok
step 2
上面那个线程是要处理输入输出的,所以不能没有,win98也是支持多线程的,我的程序为什么就跑不起来呢?请给点指。