I am using MinGW and i get this errors:
loading.cpp: In function 'bool LoadDriver(const char*, const char*)':
loading.cpp:4:5: error: 'SC_HANDLE' was not declared in this scope
loading.cpp:4:15: error: expected ';' before 'hSCService'
loading.cpp:5:15: error: expected ';' before 'hSCManager'
loading.cpp:7:5: error: 'hSCManager' was not declared in this scope
loading.cpp:7:33: error: 'NULL' was not declared in this scope
loading.cpp:7:45: error: 'SC_MANAGER_ALL_ACCESS' was not declared in this scope
loading.cpp:7:67: error: 'OpenSCManager' was not declared in this scope
loading.cpp:11:5: error: 'hSCService' was not declared in this scope
loading.cpp:12:57: error: 'SERVICE_ALL_ACCESS' was not declared in this scope
loading.cpp:12:77: error: 'SERVICE_KERNEL_DRIVER' was not declared in this scope
loading.cpp:13:57: error: 'SERVICE_DEMAND_START' was not declared in this scope
loading.cpp:13:79: error: 'SERVICE_ERROR_NORMAL' was not declared in this scope
loading.cpp:14:100: error: 'CreateService' was not declared in this scope
loading.cpp:16:44: error: 'GetLastError' was not declared in this scope
loading.cpp:16:49: error: 'ERROR_SERVICE_EXISTS' was not declared in this scope
loading.cpp:17:80: error: 'OpenService' was not declared in this scope
loading.cpp:22:44: error: 'StartService' was not declared in this scope
loading.cpp:24:26: error: 'GetLastError' was not declared in this scope
loading.cpp:24:31: error: 'ERROR_SERVICE_ALREADY_RUNNING' was not declared in th
is scope
loading.cpp:28:36: error: 'CloseServiceHandle' was not declared in this scope
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
loading.cpp:32: confused by earlier errors, bailing out
code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
bool LoadDriver( const char * cpDriverPath, const char * cpDriverName )
{
SC_HANDLE hSCService;
SC_HANDLE hSCManager;
hSCManager = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
if( hSCManager == NULL )
return false;
hSCService = CreateService( hSCManager, cpDriverName, cpDriverName,
SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER,
SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
cpDriverPath, NULL, NULL, NULL, NULL, NULL );
if( hSCService == NULL && GetLastError() == ERROR_SERVICE_EXISTS )
hSCService = OpenService( hSCManager, cpDriverName, SERVICE_ALL_ACCESS );
if( hSCService == NULL )
return false;
if( !StartService( hSCService, 0, NULL ) )
{
if( GetLastError() != ERROR_SERVICE_ALREADY_RUNNING )
return false;
}
CloseServiceHandle( hSCManager );
CloseServiceHandle( hSCService );
return true;
}
|
Where is the problem?