Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
As i implemented dll in big project,
In one module of my project,
I have the task of writing a communications library for an RS232 serial comm port magstripe reader. I am writing the library in visual C++ with MFC. The functions in this library will be called from a legacy program written in PowerBuilder 6.5. So far, PowerBuilder successfully calls the function within the dll and it works correctly, but when control returns from the dll to the PowerBuilder function, I am getting this error from PowerBuilder:
**************************************
Error Number 42<br />
at line number 1<br />
of Event open<br />
in Object w_test_window<br />
in Window w_test_window<br />
Specified argument type differs from required argument type at runtime in DLL function isbadgereaderpresent.<br />
(invalid stack pointer on return from function call)

**************************************
Here is the C++ function declaration in the dll:
extern int EXPORT IsBadgeReaderPresent(char *strComPort = "COM1")

In PowerBuilder, you have to declare a prototype for the external function. Here it is:
FUNCTION int IsBadgeReaderPresent(string strComPort) library "Cprojects\nfs_comm\nfs_comm\debug\nfs_comm. dll"
And finally, here is how the function is actually called from PowerBuilder:
IsBadgeReaderPresent("COM1")

Does anyone have any idea about why I am getting an error???
__________________
Thanks in advanced
specially all those who help me for dll implentation

EDIT:
One more bit of information:

If I take out the passed parameter, the function works as expected with no errors. This works:
extern int EXPORT IsBadgeReaderPresent()

Obviously the problem here is that I am no longer passing in the com port number that I want to check (i.e. I have to hard-code a com port number into the dll).
____________________________________________________________________
EDIT:-

I am not found the solution after spending all morning surfing Google Groups.
Is Some understand problem.
Please provide single reply

EDIT:-
_________________________________________________________________________________
I was spend 15 days on google there not solution on this.Is this bug of microsoft??????
Can any body tell me even this.............
Posted
Updated 21-Mar-11 23:08pm
v5

1 solution

Check out that you are using the right/expected calling convention:
int __stdcall IsBadgeReaderPresent(char *strComPort = "COM1")


I would have expected that EXPORT would be defined to take care of that, but with this kind of error I'd check that one out first.

Regards
Espen Harlinn
 
Share this answer
 
Comments
[no name] 13-Mar-11 23:38pm    
That make sense but not working
[no name] 15-Mar-11 7:08am    
its not proper solution this corrupts my two calls of dll

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900