Skip to content

Instantly share code, notes, and snippets.

View Sohamkadam333's full-sized avatar
🎯
Focusing

Soham Kadam Sohamkadam333

🎯
Focusing
View GitHub Profile
@Sohamkadam333
Sohamkadam333 / OpenService.cpp
Created December 12, 2023 18:56
Opens an existing service.
// OpenService function is part of the Windows API, and it is used to open a handle to an existing service in the Service Control Manager (SCM) database. The SCM is responsible for managing services on a Windows system.
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
const wchar_t *serviceName = L"AdobeARMservice";
SC_HANDLE scmHandle = OpenSCManager(NULL,NULL,SC_MANAGER_CONNECT);
@Sohamkadam333
Sohamkadam333 / EnumServicesStatus.cpp
Created December 12, 2023 18:54
Enumerates services in the specified service control manager database. The name and status of each service are provided.
// To get the service name of a running service in Windows, you can use the EnumServicesStatus function to enumerate through the services in the Service Control Manager (SCM) database and retrieve information about each service, including its name.
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
SC_HANDLE scmHandle = OpenSCManager(NULL,NULL,SC_MANAGER_CONNECT|SC_MANAGER_ENUMERATE_SERVICE);
if(scmHandle == NULL)
@Sohamkadam333
Sohamkadam333 / OpenSCManager.cpp
Created December 12, 2023 18:38
Establishes a connection to the service control manager on the specified computer and opens the specified service control manager database.
// 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);
@Sohamkadam333
Sohamkadam333 / GetLocalTime.cpp
Created December 12, 2023 18:36
Retrieves the current local date and time
// GetLocalTime function is part of the Windows API and is used to retrieve the current local system time.
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
SYSTEMTIME localTime;
GetLocalTime(&localTime);
@Sohamkadam333
Sohamkadam333 / SetFileAttributes.cpp
Created December 12, 2023 18:35
Sets the attributes for a file or directory.
// SetFileAttributes function is part of the Windows API and is used to set the attributes of a file or directory. Attributes include information such as whether the file is read-only, hidden, or system, among others.
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
const wchar_t *filePath = L"E:\\newFile.txt";
DWORD fileAttributes = FILE_ATTRIBUTE_READONLY;
@Sohamkadam333
Sohamkadam333 / GetWindowsDirectory.cpp
Created December 12, 2023 18:34
Retrieves the path of the Windows directory.
// GetWindowsDirectory function is a part of the Windows API and is used to retrieve the path of the Windows directory. The Windows directory is where the core operating system files are stored.
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
TCHAR windowsDirectory[MAX_PATH];
int result = GetWindowsDirectory(windowsDirectory,MAX_PATH);
@Sohamkadam333
Sohamkadam333 / AllocateAndInitializeSid.cpp
Created December 12, 2023 18:32
The AllocateAndInitializeSid function allocates and initializes a security identifier (SID) with up to eight subauthorities.
// AllocateAndInitializeSid function is part of the Windows API, specifically the Security Support Provider Interface (SSPI), and it is used for managing security identifiers (SIDs). SIDs are unique identifiers assigned to each security principal, such as a user or a group, in Windows.
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
PSID psid = NULL;
SID_IDENTIFIER_AUTHORITY sidAuth = SECURITY_NT_AUTHORITY;
@Sohamkadam333
Sohamkadam333 / GetSystemMetrics.cpp
Created December 12, 2023 18:28
Retrieves the specified system metric or system configuration setting.
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
int screenWidth = GetSystemMetrics(SM_CXSCREEN);
int screenHeight = GetSystemMetrics(SM_CYSCREEN);
int screenMonitors = GetSystemMetrics(SM_CMONITORS);
cout<<"Screen width = "<<screenWidth<<" px"<<endl;
@Sohamkadam333
Sohamkadam333 / GetSystemDirectory.cpp
Created December 12, 2023 18:27
Retrieves the path of the system directory. The system directory contains system files such as dynamic-link libraries and drivers.
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
TCHAR systemDirectory[MAX_PATH];
DWORD result = GetSystemDirectory(systemDirectory,MAX_PATH);
if(result !=0)
@Sohamkadam333
Sohamkadam333 / SHGetFileInfo.cpp
Created December 12, 2023 18:26
Retrieves information about an object in the file system, such as a file, folder, directory, or drive root.
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
CString filePath = L"E:\\samplefile.txt";
SHFILEINFO shfi;
ZeroMemory(&shfi,sizeof(shfi));