Click here to Skip to main content
15,896,348 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: #Region Pin
toxcct8-Dec-04 21:52
toxcct8-Dec-04 21:52 
GeneralRe: #Region Pin
Joel Lucsy10-Dec-04 4:58
Joel Lucsy10-Dec-04 4:58 
GeneralDetailed information about the error codes from LoadLibrary Pin
SteQve8-Dec-04 7:01
SteQve8-Dec-04 7:01 
Generalstatic background and WS_CLIPCHILDREN Pin
Cyrus Dang8-Dec-04 6:26
Cyrus Dang8-Dec-04 6:26 
GeneralRe: static background and WS_CLIPCHILDREN Pin
alex.barylski8-Dec-04 11:41
alex.barylski8-Dec-04 11:41 
GeneralRe: static background and WS_CLIPCHILDREN Pin
Cyrus Dang8-Dec-04 11:55
Cyrus Dang8-Dec-04 11:55 
Generalexpanding all tree items of html help Pin
includeh108-Dec-04 6:13
includeh108-Dec-04 6:13 
GeneralIssue with GetProcAddress (Resolved) Pin
Daniel Gow8-Dec-04 5:59
Daniel Gow8-Dec-04 5:59 
Hello!

I'll preface this by saying I'm a complete novice with C++; the bulk of my programming has been in VB 5/6 and VB .Net, but I have an issue with an SDK that is designed for C++, and I need it to work with VB.Net.

My issue is this; two of the functions in the DLL supplied with the SDK use a structure that has a datatype in it that is a Union (unions, of course, aren't that well supported in VB .Net). So, I decided the best route was to create my own C++ DLL that would handle the two functions that need to use this Union datatype, meaning all I would need to do is supply an input parameter (an integer in my case) and recieve and output parameter back (another integer). Calling the functions from VB .Net is easy, but that's not my problem.

I've written the C++ DLL basically by copying and pasting from the C++ header files supplied with the SDK, as that made the most sense given my lack of C++ knowledge. I have a header file that has all of the datatype definitions, an additional header file for the structure and union definitions, and then a ".cpp" file for the actual function call:

void ReturnTheDataINeed(cdHandle hEnum, cdHandle &hnd)<br />
{<br />
	HINSTANCE hLib;<br />
<br />
	cdError		err;<br />
	cdHEnum		hEnumDevice;<br />
	cdSourceInfo* pSourceInfo;<br />
	cdSourceInfo	SSrcInfo;<br />
	cdHEnum		hNext;<br />
<br />
	cdEnumDeviceNext NextDevice;<br />
<br />
	hLib = LoadLibrary("CDSDK.dll");<br />
<br />
	NextDevice = (cdEnumDeviceNext)GetProcAddress(hLib,"cdEnumDeviceNext");<br />
<br />
	pSourceInfo= new cdSourceInfo;<br />
	err = NextDevice(hEnum, pSourceInfo);<br />
	//err = cdOpenSource( &SSrcInfo, &hEnumDevice);<br />
<br />
	FreeLibrary(hLib);<br />
<br />
	hnd = hEnumDevice;<br />
};


These are the type definitions (also copied from the SDK)...

<br />
typedef unsigned long		cdError;<br />
typedef unsigned long           cdHEnum;<br />


- cdSourceInfo is a structure that holds data about the device, and I can supply the definition if it will help.

cdEnumDeviceNext is a function pointer as follows...this is copied out of the SDK's header files under 'function pointers'.

<br />
typedef cdError cdSTDCALL cdEnumDeviceNext(<br />
	cdHEnum			hEnum,	<br />
	cdSourceInfo* 	pSourceInfo<br />
);<br />


cdSTDCALL is defined as this:

<br />
#define cdSTDCALL	__stdcall<br />


And finally, I have the second function (cdOpenSource) commented out because...this dll does not build. When I attempt to build it, this line:

<br />
NextDevice = (cdEnumDeviceNext)GetProcAddress(hLib,"cdEnumDeviceNext");<br />


...throws the error "C2066: cast to function type is illegal" and what I presume is just a follow on, "C2659: '=': overloaded function as left operand".

I found the GetProcAddress and LoadLibrary calls off of the web as the defacto standard for getting functions out of dlls, but I've yet to find an explanation for my error. My current assumption is that maybe my function pointer is wrong, but I'm not certain on that because again, I copied it from the supplied header files from the SDK.

Any help that could be offered would be most appreciated.

Thank you,
Daniel Gow
GeneralRe: Issue with GetProcAddress Pin
A T I F8-Dec-04 20:58
A T I F8-Dec-04 20:58 
GeneralRe: Issue with GetProcAddress Pin
Daniel Gow9-Dec-04 2:19
Daniel Gow9-Dec-04 2:19 
GeneralRe: Issue with GetProcAddress Pin
A T I F9-Dec-04 18:35
A T I F9-Dec-04 18:35 
GeneralRe: Issue with GetProcAddress Pin
Daniel Gow11-Dec-04 13:04
Daniel Gow11-Dec-04 13:04 
QuestionNewbie Ques: How to get all Files and Directorys in a Directory? Pin
RedDragon2k8-Dec-04 5:28
RedDragon2k8-Dec-04 5:28 
AnswerRe: Newbie Ques: How to get all Files and Directorys in a Directory? Pin
BlackDice8-Dec-04 5:55
BlackDice8-Dec-04 5:55 
AnswerRe: Newbie Ques: How to get all Files and Directorys in a Directory? Pin
alex.barylski8-Dec-04 11:45
alex.barylski8-Dec-04 11:45 
QuestionHow to change SW_SHOWDEFAULT Pin
mcgahanfl8-Dec-04 4:50
mcgahanfl8-Dec-04 4:50 
AnswerRe: How to change SW_SHOWDEFAULT Pin
David Crow8-Dec-04 5:09
David Crow8-Dec-04 5:09 
General'Find' algorithm for vector using pointer to class object Pin
BlackDice8-Dec-04 4:06
BlackDice8-Dec-04 4:06 
GeneralRe: 'Find' algorithm for vector using pointer to class object Pin
Jack Puppy8-Dec-04 15:01
Jack Puppy8-Dec-04 15:01 
GeneralRe: 'Find' algorithm for vector using pointer to class object Pin
BlackDice9-Dec-04 2:42
BlackDice9-Dec-04 2:42 
GeneralRe: 'Find' algorithm for vector using pointer to class object Pin
Jack Puppy9-Dec-04 13:46
Jack Puppy9-Dec-04 13:46 
GeneralCListCtrl and Ado RecordSet Pin
shiraztk8-Dec-04 2:40
shiraztk8-Dec-04 2:40 
GeneralRe: CListCtrl and Ado RecordSet Pin
David Crow8-Dec-04 2:45
David Crow8-Dec-04 2:45 
GeneralRe: CListCtrl and Ado RecordSet Pin
shiraztk8-Dec-04 3:02
shiraztk8-Dec-04 3:02 
GeneralRe: CListCtrl and Ado RecordSet Pin
David Crow8-Dec-04 3:29
David Crow8-Dec-04 3:29 

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.