KCNet-TestDll/dllmain.cpp
2024-08-25 13:39:24 -04:00

73 lines
1.8 KiB
C++

// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#include <iostream>
#include "dllmain.h"
// https://www.tutorialspoint.com/dll/dll_writing.htm
void HelloWorld()
{
MessageBox(NULL, TEXT("Hello World"),
TEXT("In a DLL"), MB_OK);
}
// https://tbhaxor.com/loading-dlls-using-cpp-in-windows/
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpReserved) // reserved
{
// Perform actions based on the reason for calling.
#ifdef _TEST1
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// Initialize once for each new process.
//std::cout << "Test Dll attached";
std::cout << "Test Dll attached";
break;
case DLL_THREAD_ATTACH:
// Do thread-specific initialization.
break;
case DLL_THREAD_DETACH:
// Do thread-specific cleanup.
break;
case DLL_PROCESS_DETACH:
// Perform any necessary cleanup.
std::cout << "Test Dll detached";
break;
}
#endif // _TEST1
// Successful. If this is FALSE, the process will be terminated eventually
// https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-entry-point-function#entry-point-function-return-value
return TRUE;
}
// Not sure how this works
//typedef DWORD(*AddFunc)(DWORD, DWORD);
//typedef DWORD(*DivFunc)(DWORD, DWORD);
//typedef DWORD(*SubFunc)(DWORD, DWORD);
//typedef DWORD(*ProFunc)(DWORD, DWORD);
//
//EXTERN_C DWORD AddFunc(DWORD x, DWORD y) {
// return x + y;
//}
//
//EXTERN_C DWORD SubFunc(DWORD x, DWORD y) {
// return x - y;
//}
//
//EXTERN_C DWORD DivFunc(DWORD x, DWORD y) {
// return x / y;
//}
//
//EXTERN_C DWORD ProFunc(DWORD x, DWORD y) {
// return x * y;
//}