return 2*x;
}
// C language
/*extern "C" int PASCAL EXPORT Calculate (const int x)
{
return 2*x;
}*/
5. 編輯helloworld.def, 該文件顯式指明了你要到處的函數名,這里我們導出Calculate
; helloworld.def : Declares the module parameters for the DLL.
LIBRARY "helloworld"
EXPORTS
; Explicit exports can go here
Calculate
6. 編譯,在Release目錄下得到一個helloworld.dll
7.打開SilkTest新建一個project
8.新建一個hello.inc文件, 它的內容如下,注意引用dll時,請用全路徑
[-] dll "F:\VS2003\helloworld\Release\helloworld.dll"
[ ] int Calculate(int i )
9.新建一個腳本文件,它的內容如下
[ ] use "hello.inc"
[-] testcase test()
[ ] Int i
[ ] i = Calculate(5)
[ ] print(i)
10. 運行該腳本文件,它應該打印結果10
文章來源于領測軟件測試網 http://www.k11sc111.com/