【求助】关于VC++的一个线程,看不明白!!!(280分)

  • 主题发起人 主题发起人 SuKiDelphi
  • 开始时间 开始时间
S

SuKiDelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
void thread()
{
DWORD a,x
char msgbuff[512];
char *pdest;
int result;

while(1)
{
memmove(&a,&outputbuff[0],4);


if(!a){Sleep(10);continue;}



char*name=(char*)&outputbuff[8];
for(x=0;x<stringcount;x++)
{
if(!stricmp(name,strings[x])){a=1;goto skip;}
}



pdest = strstr(name,"##");
if (pdest != NULL)
{
result = pdest-name;
strcpy(msgbuff, "是否允许");
strncat(msgbuff,&amp;outputbuff[8],result);
strcat(msgbuff,"运行");
strcat(msgbuff,&amp;outputbuff[result+10]);
}
else if((pdest=strstr(name,"$$")) != NULL)
{
result = pdest-name;
strcpy(msgbuff, "是否允许");
strncat(msgbuff,&amp;outputbuff[8],result);
strcat(msgbuff,"设置注册表");
strcat(msgbuff,&amp;outputbuff[result+10]);
}
else
{
pdest = strstr(name,"&amp;&amp;");
result = pdest-name;
strcpy(msgbuff,"是否允许");
strncat(msgbuff,&amp;outputbuff[8],result);
strcat(msgbuff,"加载驱动");
strcat(msgbuff,&amp;outputbuff[result]+10);
}



if(IDYES==MessageBox(0, msgbuff,"WARNING",MB_YESNO|MB_ICONQUESTION|0x00200000L))
{
a=1

strings[stringcount]=_strdup(name);
stringcount++;
}
else a=0;


skip:memmove(&amp;outputbuff[4],&amp;a,4);


a=0;
memmove(&amp;outputbuff[0],&amp;a,4);
}

}



我一直想将上面的代码转成 Delphi 的,请大家来帮我一下,谢谢!!!
 
//没有测试,不保证完全正确。[:)]
procedure _thread()
cdecl;
var a,x:DWORD;
msgbuff:array[0..511] of char;
pdest,name:pChar;
_result:Integer;
label skip;
begin
while BOOL(TRUE) do
begin
move(outputbuff,a,4);
if BOOL(not(a)) then
begin
Sleep(10);
continue;
end;
name := pChar(@outputbuff[8]);
for x := 0 to stringcount - 1 do
begin
if BOOL(not(lstrcmpi(name,strings[x]))) then
begin
a := 1;
Goto skip;
end;
end;
pdest := pChar(Integer(name) + pos('##',name));
if pdest <> nil then
begin
_result := Integer(DWORD(pdest) - DWORD(name));
lstrcpy(msgbuff,'是否允许');
lstrcat(msgbuff,pChar(copy(outputbuff,8,_result)));
lstrcat(msgbuff,'运行');
lstrcat(msgbuff,pChar(@outputbuff[10+_result]));
end else if pos('$$',name) <> 0 then
begin
pdest := pChar(DWORD(name) + pos('$$',name));
_result := Integer(DWORD(pdest) - DWORD(name));
lstrcpy(msgbuff,'是否允许');
lstrcat(msgbuff,pChar(copy(outputbuff,8,_result)));
lstrcat(msgbuff,'设置注册表');
lstrcat(msgbuff,pChar(@outputbuff[10+_result]));
end else
begin
pdest := pChar(DWORD(name) + pos('&amp;&amp;',name));
_result := Integer(DWORD(pdest) - DWORD(name));
lstrcpy(msgbuff,'是否允许');
lstrcat(msgbuff,pChar(copy(outputbuff,8,_result)));
lstrcat(msgbuff,'加载驱动');
lstrcat(msgbuff,pChar(@outputbuff[10+_result]));
end;
if MessageBox(0, msgbuff,'WARNING',MB_YESNO or MB_ICONQUESTION or $00200000) = IDYES then
begin
a := 1;
strings[stringcount] := pChar(copy(name,0,lstrlen(name)-1));
inc(stringcount);
end else
a := 0;
skip:
move(a,outputbuff[4],4);
a := 0;
move(a,outputbuff,4);
end;
end;
 
谢谢你的热心帮助!!!
 

Similar threads

I
回复
0
查看
630
import
I
I
回复
0
查看
630
import
I
I
回复
0
查看
775
import
I
后退
顶部