我正在编写一个DLL来显示MessageBoxA
的{{1}}函数。
我不断收到错误
通过阅读某些解决方案并比较我拥有的文件,user32.dll
和main.h
具有重复的功能main.cpp
。我该如何纠正? SomeFunction
在头文件ifndef
中定义。我尝试添加内联语法,但这不起作用。
main.h
:
main.cpp
#include "main.h"
// a sample exported function
void DLL_EXPORT SomeFunction(const LPCSTR sometext)
{
MessageBoxA(0, sometext, "DLL Message", MB_OK | MB_ICONINFORMATION);
}
extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// attach to process
// return FALSE to fail DLL load
break;
case DLL_PROCESS_DETACH:
// detach from process
break;
case DLL_THREAD_ATTACH:
// attach to thread
break;
case DLL_THREAD_DETACH:
// detach from thread
break;
}
return TRUE; // succesful
}
:
main.c
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <main.h>
void Test(void)
{
MessageBoxA(
NULL,
"test",
"",
0);
}
:
main.h