Хай алл.
Где ошибка в коде
все ра ботает только в отладку лезет (возникло исключение говорит)
Код | #include <windows.h>
#ifdef BUILD_DLL #define DLL_EXPORT __declspec(dllexport) #else #define DLL_EXPORT #endif
// a sample exported function void DLL_EXPORT SomeFunction(const LPCSTR sometext) { MessageBoxA(0, sometext, "DLL Message", MB_OK | MB_ICONINFORMATION); }
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: break; case DLL_PROCESS_DETACH: break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; } return TRUE; // succesful }
#include <iostream> #include "CmnHdr.h" #include <windowsx.h> #include <stdio.h> #include <tchar.h> #include <malloc.h>
typedef void (CALLBACK* LPFNDLLFUNC1)(LPCSTR);
using namespace std;
int main() { std::cout << "Hello world!" << std::endl; HINSTANCE hinstDll = LoadLibrary(TEXT("sample")); LPFNDLLFUNC1 pfn = (LPFNDLLFUNC1)GetProcAddress(hinstDll, "SomeFunction"); LPCSTR c=(LPCSTR)"sdfsdf";
pfn(c); FreeLibrary(hinstDll);
return 0; }
|
|