Click here to Skip to main content
15,908,775 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: serial communication Pin
Rilhas9-Jul-06 5:19
Rilhas9-Jul-06 5:19 
QuestionStdAfx questions Pin
Super Lloyd3-Jul-06 17:04
Super Lloyd3-Jul-06 17:04 
AnswerRe: StdAfx questions Pin
Michael Dunn3-Jul-06 17:10
sitebuilderMichael Dunn3-Jul-06 17:10 
GeneralRe: StdAfx questions Pin
Super Lloyd3-Jul-06 18:32
Super Lloyd3-Jul-06 18:32 
AnswerRe: StdAfx questions Pin
Saurabh.Garg3-Jul-06 20:58
Saurabh.Garg3-Jul-06 20:58 
GeneralRe: StdAfx questions Pin
Super Lloyd3-Jul-06 21:07
Super Lloyd3-Jul-06 21:07 
QuestionProblem with GetProcAddress Pin
RedDragon2k3-Jul-06 16:39
RedDragon2k3-Jul-06 16:39 
AnswerRe: Problem with GetProcAddress Pin
earl3-Jul-06 17:52
earl3-Jul-06 17:52 
Hey,

You're getting a function pointer back, but GetProcAddress can't possibly know what the function definition of mmap is so you have to tell it.

Assuming that you are using the results from "man mmap"
#include      < sys/mman.h >

void*  mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);


then you would do something like this


#include < windows.h >

typedef void* (CALLBACK* PFNMMAP)(void*, size_t, int, int, int, off_t);


//blah -- open the DLL, etc

PFNMMAP pmmap;

if( (pmmap = GetProcAddress(dllHandle, "mmap"))) {


   //do something here


}


now pmmap is a function pointer with the right signature -- ie of type PFNMMAP. Oh yes, modify CALLBACK based on the way the dll export table was declared (it should work for __declexport).

Also, there are two types of libs on windows. One, called a .lib, is code made to be statically linked into a file. The other, for your convenience also called a .lib, is code that is statically linked at compile time but just thunks to a dll. The latter is often more convenient as it will handle the LoadLibrary and GetProcAddress stuff for you.

The downside to using import libs is that windows tries to load the dll before your main / WinMain is called. If it can't find the dll you never get control. At least with manual LoadLibrary calls you can be intelligent about telling the user just what you can't find and what he or she ought to do about it.

PS: I don't have a compiler on this computer so I can't promise any of this works.

HTH

earl
AnswerRe: Problem with GetProcAddress Pin
Hamid_RT3-Jul-06 20:21
Hamid_RT3-Jul-06 20:21 
Questionnewfile , new window in MDI Pin
zeus_master3-Jul-06 15:59
zeus_master3-Jul-06 15:59 
AnswerRe: newfile , new window in MDI Pin
zeus_master3-Jul-06 18:35
zeus_master3-Jul-06 18:35 
AnswerRe: newfile , new window in MDI [modified] Pin
*Dreamz3-Jul-06 20:08
*Dreamz3-Jul-06 20:08 
Questionc++ and external structs [modified] Pin
earl3-Jul-06 14:25
earl3-Jul-06 14:25 
AnswerRe: c++ and external structs Pin
Michael Dunn3-Jul-06 16:59
sitebuilderMichael Dunn3-Jul-06 16:59 
QuestionNew Dialog in a saved .exe Pin
Reagan Conservative3-Jul-06 7:05
Reagan Conservative3-Jul-06 7:05 
AnswerRe: New Dialog in a saved .exe Pin
Zac Howland3-Jul-06 7:10
Zac Howland3-Jul-06 7:10 
GeneralRe: New Dialog in a saved .exe Pin
Reagan Conservative3-Jul-06 8:20
Reagan Conservative3-Jul-06 8:20 
GeneralRe: New Dialog in a saved .exe Pin
Zac Howland3-Jul-06 8:38
Zac Howland3-Jul-06 8:38 
GeneralRe: New Dialog in a saved .exe Pin
Reagan Conservative3-Jul-06 9:56
Reagan Conservative3-Jul-06 9:56 
GeneralRe: New Dialog in a saved .exe Pin
Zac Howland3-Jul-06 12:29
Zac Howland3-Jul-06 12:29 
AnswerRe: New Dialog in a saved .exe Pin
zeus_master3-Jul-06 15:42
zeus_master3-Jul-06 15:42 
GeneralRe: New Dialog in a saved .exe Pin
Reagan Conservative5-Jul-06 5:40
Reagan Conservative5-Jul-06 5:40 
AnswerRe: New Dialog in a saved .exe Pin
dongqin3-Jul-06 18:41
dongqin3-Jul-06 18:41 
AnswerRe: New Dialog in a saved .exe Pin
MANISH RASTOGI3-Jul-06 19:52
MANISH RASTOGI3-Jul-06 19:52 
QuestionSearching for files based on regular exp. Pin
chandrasombhotla3-Jul-06 4:17
chandrasombhotla3-Jul-06 4:17 

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.