//#define WIN32_DEFAULT_LIBS
//#define WIN32_LEAN_AND_MEAN
//#include <windows.h>
//#pragma lib "kernel32.lib" // for LoadLibrary
//#pragma lib "user32.lib" // for MessageBox
int __cdecl WinMainCRTStartup(void)
{
return 0;
}
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#pragma lib "user32.lib" // for MessageBox
int __cdecl WinMainCRTStartup(void)
{
MessageBox(0, "Test", "Test", MB_OK);
return 0;
}
- PellesC doesn't have switch to output Assembler Code ?Pelles C has switches to show the assemler-output /Tx86-asm, /Tarm-asm and /Tamd64-asm. If you use one of this switches, you should rename also the output-file (/Fo) because the compiler gives the output-file the default-extension ".obj".
Stefan, i thought the Linker put in the EXE file info about which dll to load,
and the OS loader does the loading, no need for lib/user function,
so i'll have to check that.
Minimum DLL Version user32.dll Header Declared in Winuser.h, include Windows.h Import library User32.lib Minimum operating systems Windows 95, Windows NT 3.1 Unicode Implemented as ANSI and Unicode versions.
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
//#define DYNDLL
int SampleFunction(int, int);
#ifdef DYNDLL
typedef int (WINAPI SAMPLEFUNCTION)(int a, int b);
typedef SAMPLEFUNCTION *LSAMPLEFUNCTION;
#else
#pragma comment(lib, "TestDll.lib")
#endif
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
#ifdef DYNDLL
HANDLE hLib;
static LSAMPLEFUNCTION SampleFunction;
hLib = LoadLibrary("TestDLL.DLL");
SampleFunction = (LSAMPLEFUNCTION)GetProcAddress(hLib, "SampleFunction");
#endif
SampleFunction(0, 0);
#ifdef DYNDLL
FreeLibrary(hLib);
#endif
return 0;
}
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
BOOL __stdcall DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
int __declspec( dllexport ) __stdcall SampleFunction(int a, int b)
{
MessageBox(0, "SampleFunction", "TestDLL", MB_OK);
return a * b;
}
declare sub foo lib "kernel.dll"