问几个C转成DELPHI的问题,在线等待....(50分)

  • 主题发起人 主题发起人 wjames
  • 开始时间 开始时间
W

wjames

Unregistered / Unconfirmed
GUEST, unregistred user!
int ParseCmdLine(int argc,char *argc[]);
void *InterfaceThread(void *arg);
void RegisterPlugin(char *,void(*func)(char *,OptTreeNode *,int));
void AddFuncToRestartList(void (*func)(int,void *),void*);
这些函数在delphi中应该怎么写啊,如果分不够可以再加的
 
function ParseCmdLine(argc: Integer argc: PPChar): Integer;
---
type
procedure TInterfaceThread(arg: Pointer);
PInterfaceThread: ^TInterfaceThread;
---
第三个不会
---
第四个也不会
 
鄙视c,鄙视c++
都是让人看不懂的东西:)
 
void RegisterPlugin(char *,void(*func)(char *,OptTreeNode *,int));
->
type
TFunc = procedure(c: pchar
node: ^OptTreeNode
i: integer);
...
procedure RegisterPlugin(ch: pchar
func: TFunc);

最后一个类似。

 
还有个问题,在C中memcpy到了Delphi中应该用哪个函数来替换???
 
用Win32的CopyMemory:
he CopyMemory function copies a block of memory from one location to another.

VOID CopyMemory (
PVOID Destination, // address of copy destination
CONST VOID *Source, // address of block to copy
DWORD Length // size, in bytes, of block to copy
);
Parameters

Destination

Points to the starting address of the copied block's destination.

Source

Points to the starting address of the block of memory to copy.

Length

Specifies the size, in bytes, of the block of memory to copy.



Return Values

This function has no return value.

Remarks

If the source and destination blocks overlap, the results are undefined. For overlapped blocks, use the MoveMemory function.
 
在Delphi的申明为在Windows单元:
procedure CopyMemory(Destination: Pointer
Source: Pointer
Length: DWORD);

Delphi Mxarrays中的用法:
procedure TBaseArray.GetItem(index: Integer
var Value);
begin
if ValidIndex(index) then
begin
try
CopyMemory(@Value, GetItemPtr(index), FItemSize);
except
InternalHandleException;
end;
end;
end;

function TBaseArray.GetItemPtr(index: Integer): Pointer;
begin
Result := nil

if ValidIndex(index) then
Result := Ptr(LongInt(FMemory) + (index*FItemSize));
end;
 
那这个怎么换成delphi 呢?
char m_grpBuffer [128 * 1024];
DWORD dwOfsList= (DWORD *)&m_grpBuffer[12];
int ID;
char *stream;
memcpy((void *)stream.(void *)&m_grpBuffer[dwOfsList[ ID * 2]],dwOfsList);
 
还有一句
stream[dwOfsList[Id * 2]] = 0x0a;
 
多人接受答案了。
 
后退
顶部