如果你也对股票交易接口dll有兴趣,其实大可以自己编写一个,但在此之前,你需要一个c/c++编译器和链接器,并关闭你的IDE。要知道,最简单的dll并不比c的helloworld难,只要一个DllMain函数即可。 首先创建 一个DLL程序,.cpp中 int __stdcall Add(int numa, int numb) { return (numa + numb); } int __stdcall Sub(int numa, int numb) { return (numa - numb); } 然后创建一个.def的文件,在里面加上 ;DllTestDef.lib : 导出DLL函数 ;作者:---- LIBRARY DllTestDef EXPORTS Add @ 1 Sub @ 2 最后创建一个测试程序:.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语言的动态链接技术,在输出C函数和变量时显得方便快捷,如果我们编辑股票交易接口时,使用c语言,那dll我们是逃不开的。股票交易接口中的dll作为动态库,对于股市每日能产生海量数据的来源是很有用的,所以大家考虑开发股票交易接口的话,dll库可以多研究研究。 |
|