Skip to content

Instantly share code, notes, and snippets.

@6661620a
Forked from reigningshells/Cplapplet.cpp
Created August 3, 2023 11:11
Show Gist options
  • Select an option

  • Save 6661620a/49e0f7f41c5e090ed02399cf6dbb40c6 to your computer and use it in GitHub Desktop.

Select an option

Save 6661620a/49e0f7f41c5e090ed02399cf6dbb40c6 to your computer and use it in GitHub Desktop.
DllMain template to execute code in a .cpl file which is just a renamed DLL that exports a function CplApplet
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#include <Windows.h>
extern "C" __declspec(dllexport) LONG CplApplet()
{
MessageBoxA(NULL, "Replace this message box with something more interesting...", "Control Panel", 0);
return 1;
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
CplApplet();
}
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment