#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <windows.h>
using namespace std;
HMODULE GetSelfModuleHandle()
{
MEMORY_BASIC_INFORMATION mbi;
return ((::VirtualQuery(GetSelfModuleHandle, &mbi, sizeof(mbi)) != 0) ? (HMODULE)mbi.AllocationBase : NULL);
}
extern "C" __declspec(dllexport) int GetDllPath(){
ifstream file;
char curDir[100] = {0};
GetModuleFileName(GetSelfModuleHandle(),curDir,100);
cout<<"Dll Path:"<<curDir<<endl;
return 0;
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
cout<<"DllMain called"<<endl;
return TRUE;
}
C++在dll中获取自身路径(非exe调用路径)
最新推荐文章于 2024-09-18 07:33:00 发布