Click here to Skip to main content
16,011,868 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Is there a way to put a thread to sleep remotely? Pin
JohnnyG16-Jul-02 9:24
JohnnyG16-Jul-02 9:24 
AnswerRe: Is there a way to put a thread to sleep remotely? Pin
Daniel Lohmann17-Jul-02 14:16
Daniel Lohmann17-Jul-02 14:16 
Generalmsword automation, open Pin
pnpfriend16-Jul-02 8:53
pnpfriend16-Jul-02 8:53 
QuestionCToolBar, a vertical line ? Pin
includeh1016-Jul-02 8:51
includeh1016-Jul-02 8:51 
AnswerRe: CToolBar, a vertical line ? Pin
Shog916-Jul-02 8:55
sitebuilderShog916-Jul-02 8:55 
GeneralRe: CToolBar, a vertical line ? Pin
includeh1016-Jul-02 9:20
includeh1016-Jul-02 9:20 
GeneralRe: CToolBar, a vertical line ? Pin
Shog916-Jul-02 9:33
sitebuilderShog916-Jul-02 9:33 
Generaldll -where should I start Pin
melshehu200216-Jul-02 8:46
melshehu200216-Jul-02 8:46 
I am trying to learn how to create and use dll, but so far I haven't been able to even print a "hello" message on the screen. I am reading instructions at msdn library, but can't find what I need. I need instructions(basic) on how to create and load dll. Any simplest examples(say to print "hello" using dll)anyone could send me I would appreciate.
Is there any book about dll, or any website?
A project I created gives me 2 errors("could not get function 1 process address")when is executed; it is compiled without errors.

Here is my .def file:"
LIBRARY prcAttach
DESCRIPTION "Where the functions really live"
EXPORTS
function1 @1
function2 @2 "

I set "Not Using MFC" in Project/settings/general because that's what a friend of mine uses and his project works fine.

Here is my dllLoad.cpp file
#include <windows.h>
#include <iostream>



//typedef for a: int function1(int i);
typedef int (*F1)(int);

//typedef for a: char function2(char c);
typedef char (*F2)(char);

int main(int argc, char * argv[])
{
HMODULE hDll;
F1 func1;
F2 func2;

hDll=LoadLibrary("prcAttach.dll");
if(hDll==NULL)
std::cout << "Could not load dll" << std::endl;
else
{
MessageBox(NULL,"Library loaded","dllLoad",MB_OK);
func1=(F1)GetProcAddress(hDll,"function1");
if(func1==NULL)
std::cout << "Could not get function 1 proc address" << std::endl;
func2=(F2)GetProcAddress(hDll,"function2");
if(func2==NULL)
std::cout << "Could not get function 2 proc address" << std::endl;
MessageBox(NULL,"functions found","dllLoad",MB_OK);
MessageBox(NULL,"Hello","dllLoad",MB_OK);

func1(1);
func2('a');

FreeLibrary(hDll);
}

return 0;
}

Here is my prcAttach.cpp file(prc-short for process)

#include <windows.h>
void ShowMessage(char const * szcM)
{
MessageBoxEx(NULL,szcM,"HostDLL",MB_OK,LANG_ENGLISH);
}
extern "C"
{
int function1(int i) {ShowMessage("I changed hostdll function 1");return i;}
char function2(char c) {ShowMessage("hostdll function 2");return c;}
}

BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID
lpvReserved)
{
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
// Initialize once for each new process.
// Return FALSE to fail DLL load.
DisableThreadLibraryCalls(hinstDLL); // Remove to allow multiple threads to attach
break;
/* uncomment this block to handle multiple thread attachments
case DLL_THREAD_ATTACH:
//Do thread-specific initialization
break;
case DLL_THREAD_DETACH
//Do thread-specific cleanup
break;
*/
case DLL_PROCESS_DETACH:
// Perform any necessary cleanup.
break;
}
return TRUE; // Successful DLL_PROCESS_ATTACH.
}

Could anyone help please!
thanks in advance



mel
GeneralRe: dll -where should I start Pin
Joaquín M López Muñoz16-Jul-02 8:58
Joaquín M López Muñoz16-Jul-02 8:58 
Generalchanging text on menu item Pin
ns16-Jul-02 8:33
ns16-Jul-02 8:33 
GeneralRe: changing text on menu item Pin
Nish Nishant16-Jul-02 8:44
sitebuilderNish Nishant16-Jul-02 8:44 
Generalsorry for two threads - my browser was acting up Pin
ns16-Jul-02 9:03
ns16-Jul-02 9:03 
Generalchange caption of the menu item - quick question Pin
ns16-Jul-02 8:24
ns16-Jul-02 8:24 
GeneralRe: change caption of the menu item - quick question Pin
Nish Nishant16-Jul-02 8:27
sitebuilderNish Nishant16-Jul-02 8:27 
Generalquestion about modify menu - sort of works Pin
ns16-Jul-02 9:02
ns16-Jul-02 9:02 
GeneralRe: change caption of the menu item - quick question Pin
ns16-Jul-02 9:52
ns16-Jul-02 9:52 
Generalvalues not showing up in array Pin
John Aldrich16-Jul-02 7:59
John Aldrich16-Jul-02 7:59 
GeneralRe: values not showing up in array Pin
Nish Nishant16-Jul-02 8:11
sitebuilderNish Nishant16-Jul-02 8:11 
GeneralRe: values not showing up in array Pin
Nish Nishant16-Jul-02 8:13
sitebuilderNish Nishant16-Jul-02 8:13 
GeneralRe: values not showing up in array Pin
John Aldrich16-Jul-02 8:18
John Aldrich16-Jul-02 8:18 
GeneralRe: values not showing up in array Pin
Nish Nishant16-Jul-02 8:24
sitebuilderNish Nishant16-Jul-02 8:24 
GeneralQuick menu question..... Pin
Nitron16-Jul-02 7:43
Nitron16-Jul-02 7:43 
GeneralRe: Quick menu question..... Pin
Nish Nishant16-Jul-02 8:15
sitebuilderNish Nishant16-Jul-02 8:15 
GeneralRe: Quick menu question..... Pin
Nitron16-Jul-02 8:32
Nitron16-Jul-02 8:32 
GeneralRe: Quick menu question..... Pin
Nish Nishant16-Jul-02 8:39
sitebuilderNish Nishant16-Jul-02 8:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.