S
sun_8113
Unregistered / Unconfirmed
GUEST, unregistred user!
我用BCB写了个方法如下:
extern "C"
void __declspec(dllexport) __stdcall CreateEncrypt(char * FileName);
extern "C"
void __declspec(dllexport) __stdcall WriteEncrypt(void * buffer,unsigned long FBufferSize);
extern "C"
void __declspec(dllexport) __stdcall CloseEncrypt();
CEvFile *pevf;
void __stdcall CreateEncrypt(char * FileName)
{
pevf = new CEvFile();
pevf->Create(FileName);
}
void __stdcall WriteEncrypt(void * buffer,unsigned long FBufferSize)
{
pevf->Write(buffer,FBufferSize);
}
void __stdcall CloseEncrypt()
{
pevf->Close();
delete pevf;
pevf = NULL;
}
procedure CreateEncrypt(FileNamechar);stdcall;
external 'FileEncrypt.dll';
procedure WriteEncrypt(buffer: pointer;
FBufferSize: LongWord);stdcall;
external 'FileEncrypt.dll';
procedure CloseEncrypt();stdcall;
external 'FileEncrypt.dll';
用delphi调用
hFile := FileOpen('d:/30003.vob',fmOpenRead);
if (hfile = INVALID_HANDLE_VALUE) then
ShowMessage('fff');
CreateEncrypt('c:/aa.mpg');
buffer := GetMemory(1024*10);
//(buffer,1024*10);
while truedo
begin
BytesReturn := FileRead(hFile,buffer,1024*10);
if BytesReturn = 0 then
break;
WriteEncrypt(pointer(buffer),BytesReturn);
//这里传指针过去值会丢失,是不是我写的有问题
end;
FreeMemory(buffer);
CloseEncrypt();
FileClose(hFile);
ShowMessage('加密完成');
extern "C"
void __declspec(dllexport) __stdcall CreateEncrypt(char * FileName);
extern "C"
void __declspec(dllexport) __stdcall WriteEncrypt(void * buffer,unsigned long FBufferSize);
extern "C"
void __declspec(dllexport) __stdcall CloseEncrypt();
CEvFile *pevf;
void __stdcall CreateEncrypt(char * FileName)
{
pevf = new CEvFile();
pevf->Create(FileName);
}
void __stdcall WriteEncrypt(void * buffer,unsigned long FBufferSize)
{
pevf->Write(buffer,FBufferSize);
}
void __stdcall CloseEncrypt()
{
pevf->Close();
delete pevf;
pevf = NULL;
}
procedure CreateEncrypt(FileNamechar);stdcall;
external 'FileEncrypt.dll';
procedure WriteEncrypt(buffer: pointer;
FBufferSize: LongWord);stdcall;
external 'FileEncrypt.dll';
procedure CloseEncrypt();stdcall;
external 'FileEncrypt.dll';
用delphi调用
hFile := FileOpen('d:/30003.vob',fmOpenRead);
if (hfile = INVALID_HANDLE_VALUE) then
ShowMessage('fff');
CreateEncrypt('c:/aa.mpg');
buffer := GetMemory(1024*10);
//(buffer,1024*10);
while truedo
begin
BytesReturn := FileRead(hFile,buffer,1024*10);
if BytesReturn = 0 then
break;
WriteEncrypt(pointer(buffer),BytesReturn);
//这里传指针过去值会丢失,是不是我写的有问题
end;
FreeMemory(buffer);
CloseEncrypt();
FileClose(hFile);
ShowMessage('加密完成');