請教: 請大俠解釋一下下面的程式碼?(早知道這樣早點開始學 C/C++)
简叔 2003-12-17 04:59:50 以前從未碰過 C/C++,, 因工作需要,真的是沒辦法,請詳細解釋一下面程式在作用?
為什麼要這樣做?(我只知道不這樣做 pl/sql ora_ffi.load_dll 的程式就執行不成功)
程式中的 * 和 & 和 C# 中的那個 Operator 相當? 謝謝!!
/*
Card.c
This file, compiled as Card.dll(CL /LD card.c /link.dcrf32.lib), serves as a Win32 interface for Card.pll.
The purpose of card.c is to solve the problem of incompatibility between dcrf32.dll
and PL/SQL.
*/
#include <windows.h>
/* 9 */ __declspec(dllimport) __int16 __stdcall dc_read(HANDLE icdev, unsigned char _Adr, unsigned char *_Data);
BOOL WINAPI DllEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason,
LPVOID lpvReserved)
{
return TRUE;
}
/*
Read the data from a section in ASCII
*/
__declspec(dllexport) unsigned char * my_read(HANDLE icdev, int _Adr)
{
int st;
unsigned char adr = _Adr;
unsigned char data[16] = {0};
unsigned char *copy;
int len;
st = dc_read(icdev, adr, data);
len = strlen(data);
copy = (char *)malloc(sizeof(char) * (len + 1));
strcpy(copy, data);
if (st!=0)
return "ERROR";
else
return copy;
}