使用commport时错误返回dll函数 [英] Wrong return of dll function while using commport

查看:88
本文介绍了使用commport时错误返回dll函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在大型项目中实施dll时,
在我的项目的一个模块中,
我的任务是为RS232串行comm端口magstripe阅读器编写通信库.我正在使用MFC在Visual C ++中编写该库.该库中的函数将从PowerBuilder 6.5编写的旧版程序中调用.到目前为止,PowerBuilder成功地在dll中调用了该函数,并且可以正常工作,但是当控件从dll返回到PowerBuilder函数时,我从PowerBuilder中得到了此错误:
******************************************

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)


******************************************
这是dll中的C ++函数声明:


**************************************
Here is the C++ function declaration in the dll:

extern int EXPORT IsBadgeReaderPresent(char *strComPort = "COM1")


在PowerBuilder中,您必须为外部函数声明一个原型.这是:
函数int IsBadgeReaderPresent(string strComPort)库"Cprojects \ nfs_comm \ nfs_comm \ debug \ nfs_comm.dll"
最后,这是从PowerBuilder实际调用该函数的方式:


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")


有谁知道为什么我会出错吗???
__________________
感谢进阶
特别是所有那些帮助我实现dll实现的人


更多信息:

如果我删除了传递的参数,该函数将按预期工作,不会出现错误.这有效:
extern int EXPORT IsBadgeReaderPresent()

显然,这里的问题是我不再传递要检查的com端口号(即我必须将com端口号硬编码到dll中).
____________________________________________________________________
-

整个上午都在Google网上冲浪后,我没有找到解决方案.
是一些理解的问题.
请提供单个答复

-
_________________________________________________________________________________
我在Google上呆了15天,对此没有解决方案.这是Microsoft的错误吗?????
任何人都可以告诉我..............


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


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).
____________________________________________________________________
-

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

-
_________________________________________________________________________________
I was spend 15 days on google there not solution on this.Is this bug of microsoft??????
Can any body tell me even this.............

推荐答案

检查您使用的是正确的/预期的调用约定:
Check out that you are using the right/expected calling convention:
int __stdcall IsBadgeReaderPresent(char *strComPort = "COM1")



我本来希望可以定义EXPORT来解决这一问题,但是由于出现这种错误,我会先检查一下.

问候
Espen Harlinn



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


这篇关于使用commport时错误返回dll函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆