#define SERVICE_NAME (LPWSTR)"LISTENER"
void WINAPI SvcMain(DWORD dwArgc, LPWSTR* lpszArgv);
void SvcReportEvent(LPWSTR lpszFunction, DWORD dwErr = 0);
void _tmain()
{
execmd();
strcat(pl,"\\adb devices");//把后面的字符串添加到前面的字符串后面
strcat(pn,"\\adb start-server");
dispatchTable[] =
{
{ SERVICE_NAME, (LPSERVICE_MAIN_FUNCTION)SvcMain },
{ NULL, NULL }
};
if (!StartServiceCtrlDispatcher(dispatchTable))
{
SvcReportEvent(L"StartServiceCtrlDispatcher", GetLastError());
}
return;
}
我搞不懂的地方是
dispatchTable[] =
{
{ SERVICE_NAME, (LPSERVICE_MAIN_FUNCTION)SvcMain },
{ NULL, NULL }
};
这一段是什么意思,dispatchtable是windows内部函数吗?为什么(LPSERVICE_MAIN_FUNCTION)SvcMain可以这样表达?{ NULL, NULL }这又代表什么意思呢?
C Windows winapi 编程 函数
------解决方案--------------------
MSDN
===============================================
StartServiceCtrlDispatcher function
Connects the main thread of a service process to the service control manager, which causes the thread to be the service control dispatcher thread for the calling process.
Syntax
C++
BOOL WINAPI StartServiceCtrlDispatcher(
_In_ const SERVICE_TABLE_ENTRY *lpServiceTable
);
Parameters
lpServiceTable [in]
A pointer to an array of SERVICE_TABLE_ENTRY structures containing one entry for each service that can execute in the calling process. The members of the last entry in the table must have NULL values to designate the end of the table.
Return value