Testpartner 如何調用C++ dll

發表于:2008-04-23來源:作者:點擊數: 標簽:TestpartnerdllTestPartner
Testpartner 如何調用C++ dll Testpartner是一個非常容易上手的 自動化測試 工具。它的 腳本語言 是 VB A.所以功能上也是非常強大的. 很多人對VB都抱有一定的成見,認為其功能不強,用C++ 開發 才是真材實料.不過這也是仁者見仁,智者見智.我覺得這就像是兩種武
Testpartner 如何調用C++ dll Testpartner是一個非常容易上手的自動化測試工具。它的腳本語言VBA.所以功能上也是非常強大的. 很多人對VB都抱有一定的成見,認為其功能不強,用C++開發才是真材實料.不過這也是仁者見仁,智者見智.我覺得這就像是兩種武功一樣,vb就像是輕功,c++則是內功,各有所強.輕功的特點就是快,vb開發就是快,傳說中bill gates總能用vb解決其他人認為不可能用vb解決的問題。所以,對軟件應用的人來說技術的多樣性恰似條條大路通羅馬,我們就是要從中找出最近的那條. 最近,遇到個測試問題,業務上已經用C++來實現,為了能夠在最短的時間內使其能夠自動化,必須嵌入到TestPartner.這就涉及到如何在vb中調用C++代碼的問題。網上資料還是不少的,所以很快就完成了。其中的一個關鍵就是將C++的函數調用方式改成__stdcall.在vb中寫了個測試程序也通過了。但是相同的代碼嵌入到TestPartner,就出現了一個錯誤,“Bad dll calling convention”. 看了一下幫助,還是圍繞著函數調用方式這個問題。 Bad DLL calling convention (Error 49)

   

Arguments passed to a dynamic-link library (DLL) or Macintosh code resource routine must exactly match those expected by the routine. Calling conventions deal with number, type, and order of arguments. This error has the following causes and solutions: Your program is calling a routine in a DLL (in Windows) or a code resource (on the Macintosh) that's being passed the wrong type of arguments.

Make sure all argument types agree with those specified in the declaration of the routine you are calling.

Your program is calling a routine in a DLL (in Windows) or a code resource (on the Macintosh) that's being passed the wrong number of arguments.

Make sure you are passing the same number of arguments indicated in the declaration of the routine you are calling.

Your program is calling a routine in a DLL, but isn't using the StdCall calling convention.

If the DLL routine expects arguments by value, then make sure ByVal is specified for those arguments in the declaration for the routine.

Your Declare statement for a Windows DLL includes CDecl.

The CDecl keyword applies only to the Macintosh.

For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).

 我明明是用了__stdcall,為什么還會有錯誤呢?再說了,相同的代碼在vb中也是可以被正常執行的.難道說Testpartner中的vb為非標準的vb?于是,我就想試一下其他的window api是否能夠被正常調用。copy了個sleep的聲明 Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Declare Function HelloWorld Lib "Test.dll" () 突然發現了一個與自己聲明不一致的地方,那就是我用了Function來聲明這個沒有返回值得函數。在vb中,沒有返回值得函數應該用sub. 于是改了一下,錯誤也就不在了。   看來,Testpartner的vb環境比標準vb IDE在語法上要求更嚴格!

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97