I have created an *.exe
and *.dll
for my project.
I have provided all the correct path and data.
Myexe.cpp
:
#include "stdafx.h"
#include <Windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
HMODULE hInstLibrary = LoadLibrary(L("..\\Debug\\LoadDLL\\LoadDLL.dll"));// I have checked with complete path as well.
if(hInstLibrary)
{
printf("Hello World");
}
return 0;
}
MyDLL.cpp
:
#include "MyDLL.h"
#include <stdio.h>
MyDLL::MyDLL(void)
{
}
MyDLL::~MyDLL(void)
{
}
extern "C" __declspec(dllexport) void HelloWorld()
{
printf("Hello DLL");
}
MyDLL.h
:
#pragma once
class __declspec(dllexport) MyDLL
{
public:
MyDLL(void);
~MyDLL(void);
};
extern "C" __declspec(dllexport) void HelloWorld();
I have tried providing the complete path
also. But it is still failing. The hInstLibrary
is setting to 0x00000
. I tried in Release mode
too but the problem still lies there.
But when I have tried with:
HMODULE hInstLibrary = LoadLibrary(_T("C:\\Windows\\System32\\aeinv.dll"));
it does load the DLL
. So, please help me where is it going wrong. The DLL gets build properly, there is absolutely no error in building DLL. Then why am I facing this problem??
Is there any setting need to be done for Debug
.
You need to call GetLastError to find out what went wrong.
Edit:
You got 0x7e, which means:
ERROR_MOD_NOT_FOUND
126 (0x7E)
The specified module could not be found.
Your path is wrong. You need to fix that.