#include "stdafx.h"
using namespace std;
int main(int argc, char* argv[])
{
if (argc == 1)
{
cout << "Please specify dll name with \".dll\" as argument" << endl;
}
else
{
char* libName = argv[1];
HMODULE handle = LoadLibraryA(libName);
if (handle)
cout << "Successfully loaded" << endl;
else
{
LPWSTR lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
//cout << "Error:\n" << lpMsgBuf << endl;
MessageBoxW(0, lpMsgBuf, L"GetLastError()", MB_ICONERROR);
// Free the buffer.
LocalFree( lpMsgBuf );
}
}
system("pause");
return 0;
}


void TheThread()
{
while (true)
{
Sleep(1);
//Your messagebox here
}
}
BOOL WINAPI DllMain(HMODULE dHandle, DWORD nReason, LPVOID Reserved)
{
if(nReason == DLL_PROCESS_ATTACH)
{
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)TheThread, NULL, NULL, NULL);
}
return TRUE;
}
#include "windows.h"
#include <iostream>
int main()
{
DWORD err;
HINSTANCE hDLL = LoadLibrary("CShell.dll"); // Handle to DLL
if(hDLL != NULL) {
printf("Library has been loaded\n");
}
else {
err = GetLastError();
printf("Couldn't load dll\n");
}
system("pause");
return 0;
}
I'll try compile with 2012 version (probably *80 DLL's corresponds to VS 2012 runtime)