Thank you Govtcheez
and thus, I have come to one more question about DLLs. Very interesting things these are, infact.
Here's my DLL:
dll.h
Code:
#include "dll.h"
#include <windows.h>
#include <iostream>
DllClass::DllClass()
{}
DllClass::~DllClass ()
{}
int DllClass::helloWorld()
{
std::cout << "Hello World!";
return 0;
}
BOOL APIENTRY DllMain
(
HINSTANCE hInst
/* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */
)
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
/* Returns TRUE on success, FALSE on failure */
return TRUE;
}
dllmain.cpp
Code:
#ifndef _DLL_H_
#define _DLL_H_
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
class DLLIMPORT DllClass
{
public:
DllClass();
virtual ~DllClass(void);
int helloWorld();
};
#endif /* _DLL_H_ */
Here's my program that I want to call the DLL correctly:
main.cpp
Code:
#include <stdlib.h>
#include <windows.h>
int main(int argc, char *argv[])
{
LoadLibrary("dll.dll");
if(DllClass::helloWorld() = 0)
std::cout << "\nSuccess!";
else
std::cout << "Output failed for some weird reason~!";
system("PAUSE");
return 0;
}
It gives me: helloWorld() undeclared (first use this function), and yet helloWorld is in my DLL. I've also tried DllClass::helloWorld(), btw.