如果你也對股票交易接口dll有興趣,其實(shí)大可以自己編寫(xiě)一個(gè),但在此之前,你需要一個(gè)c/c++編譯器和鏈接器,并關(guān)閉你的IDE。要知道,最簡(jiǎn)單的dll并不比c的helloworld難,只要一個(gè)DllMain函數即可。
首先創(chuàng )建 一個(gè)DLL程序,.cpp中
int __stdcall Add(int numa, int numb)
{
return (numa + numb);
}
int __stdcall Sub(int numa, int numb)
{
return (numa - numb);
}
然后創(chuàng )建一個(gè).def的文件,在里面加上
;DllTestDef.lib : 導出DLL函數
;作者:----
LIBRARY DllTestDef
EXPORTS
Add @ 1
Sub @ 2
最后創(chuàng )建一個(gè)測試程序:.cpp文件如下:
#include <iostream>
#include <windows.h>
using namespace std;
typedef int (__stdcall *FUN)(int, int);
HINSTANCE hInstance;
FUN fun;
int main()
{
hInstance = LoadLibrary("DLLTestDef.dll");
if(!hInstance)
cout << "Not Find this Dll" << endl;
fun = (FUN)GetProcAddress(hInstance, MAKEINTRESOURCE(1));
if (!fun)
{
cout << "not find this fun" << endl;
}
cout << fun(1, 2) << endl;
FreeLibrary(hInstance);
return 0;
}
大家要記得,DLL是對應C語(yǔ)言的動(dòng)態(tài)鏈接技術(shù),在輸出C函數和變量時(shí)顯得方便快捷,如果我們編輯股票交易接口時(shí),使用c語(yǔ)言,那dll我們是逃不開(kāi)的。股票交易接口中的dll作為動(dòng)態(tài)庫,對于股市每日能產(chǎn)生海量數據的來(lái)源是很有用的,所以大家考慮開(kāi)發(fā)股票交易接口的話(huà),dll庫可以多研究研究。
聯(lián)系客服