调用dll 的问题
本人为初学者 学习中遇到一个问题 特来请求各位帮助
拿到一个 dll 文件 只有 bcb 的调用方法 我想在delphi 中调用
dll: Key.dll
bcb 调用方法 在项目中包含 Key_import.h Key_import.cpp
——-----------------------------------------------------------
Key_import.h 内容:
#ifndef KEY_IMPORT_H
#define KEY_IMPORT_H
enum { KS_SAMPLE_RATE, KS_CHANNELS, KS_ANTI_ALIAS, KS_SHIFT_KEY };
typedef HKEY;
typedef __declspec(dllimport) HKEY (__stdcall *IKey_Create)();
typedef __declspec(dllimport) void (__stdcall *IKey_Set)(HKEY ksHandle, int property, int value);
typedef __declspec(dllimport) void (__stdcall *IKey_PutSamples)(HKEY ksHandle, short int * data, int dataSize );
typedef __declspec(dllimport) int (__stdcall *IKey_GetSamples)(HKEY ksHandle, short int * data, int maxSize, int * inSize );
extern IKey_Create Key_Create;
extern IKey_Set Key_Set;
extern IKey_PutSamples Key_PutSamples;
extern IKey_GetSamples Key_GetSamples;
int InitKeyLib();
#endif
——-----------------------------------------------------------
Key_import.cpp 内容
#include "Windows.h"
#include "Key_import.h"
IKey_Create Key_Create;
IKey_Set Key_Set;
IKey_PutSamples Key_PutSamples;
IKey_GetSamples Key_GetSamples;
int InitKeyLib()
{
HINSTANCE KeyLibDll;
KeyLibDll = LoadLibrary( "Key.dll" );
if (KeyLibDll == NULL)
return -1;
Key_Create = (IKey_Create)GetProcAddress( KeyLibDll, "Key_Create" );
Key_Set = (IKey_Set)GetProcAddress( KeyLibDll, "Key_Set" );
Key_PutSamples = (IKey_PutSamples)GetProcAddress( KeyLibDll, "Key_PutSamples" );
Key_GetSamples = (IKey_GetSamples)GetProcAddress( KeyLibDll, "Key_GetSamples" );
if ((!Key_Create) || (!Key_Set) || (!Key_PutSamples) || (!Key_GetSamples))
return 0;
return 1;
}
——-----------------------------------------------------------
期望各位大佬能够帮忙把这俩引用文件转为.pas 我在这里先谢过了