Created
December 12, 2023 18:38
-
-
Save Sohamkadam333/2b1a106dcc2418f442eda9189d11596c to your computer and use it in GitHub Desktop.
Establishes a connection to the service control manager on the specified computer and opens the specified service control manager database.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OpenSCManager function is part of the Windows API, and it is used to open a handle to the Service Control Manager (SCM) database on a local or remote computer. The SCM is responsible for managing services on a Windows system. | |
#include <iostream> | |
#include <windows.h> | |
using namespace std; | |
int main() | |
{ | |
// OpenSCM | |
SC_HANDLE scmHandle = OpenSCManager(NULL,NULL,SC_MANAGER_CONNECT); | |
if(scmHandle != NULL) | |
{ | |
cout<<"Service Control Manager handle Opened Successfully "<<endl; | |
CloseServiceHandle(scmHandle); | |
cout<<"Service Control Manager handle Closed Successfully "<<endl; | |
} | |
else | |
{ | |
cerr<<"Error Opening Service Control Manager, Error No : "<<GetLastError(); | |
} | |
system("PAUSE"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment