0X10.cpp
上传用户:hyz2004817
上传日期:2022-03-30
资源大小:226k
文件大小:2k
- #include "stdafx.h"
- extern HANDLE g_hExitEvent;
- //////////////////////////////////////////////////////////////
- //
- // 通过调用 ShellExecute 函数创建一个进程
- //
- BOOL
- WINAPI
- RCAID_0X10_HANDLER(
- SOCKET s,
- RCAREQUESTHANDLEDATA * pData,
- RCAREQUESTHEADER * pRCAHead,
- HANDLE hEventArray[2]
- )
- {
- // 计算需要接收的总字节数
- int c = pRCAHead->requestBytes - sizeof( RCAREQUESTHEADER );
- char * buf;
- int ret;
-
- if( c <= 20 )
- return FALSE;
- buf = (char*)new char[c];
-
- if( buf == NULL )
- return TRUE;
- ret = RCARecv_EventSelectIO( s, hEventArray, buf, c );
- if( ret != c )
- {
- delete[] buf;
- return FALSE;
- }
- char * p = buf;
- DWORD strLength;
- p = buf;
- HWND hWnd = (HWND)(*p);
- p += 4;
- if( (p-buf) > c )
- goto request_end;
- char *pOperation, *pFile, *pParam, *pDirectory;
- strLength = (DWORD)*p;
-
- if( (DWORD)(*p) > 0 )
- pOperation = p + 4;
- else
- pOperation = NULL;
- p += (4 + strLength);
- if( (p-buf) > c )
- goto request_end;
- strLength = (DWORD)*p;
- if( (DWORD)(*p) > 0 )
- pFile = p + 4;
- else
- pFile = NULL;
- p += (4 + strLength);
- if( (p-buf) > c )
- goto request_end;
- strLength = (DWORD)*p;
- if( (DWORD)(*p) > 0 )
- pParam = p + 4;
- else
- pParam = NULL;
-
- p += (4 + strLength);
- if( (p-buf) > c )
- goto request_end;
- strLength = (DWORD)*p;
- if( (DWORD)(*p) > 0 )
- pDirectory = p + 4;
- else
- pDirectory = NULL;
- p += (4 + strLength);
- if( (p-buf) > c )
- goto request_end;
- int nShowCmd = (int)*p;
- ShellExecute( hWnd, pOperation, pFile, pParam, pDirectory, nShowCmd );
- request_end:
- delete[] buf;
- return TRUE;
- }