将C++Builder 代码转化为 Delphi代码 (200分)

  • 主题发起人 主题发起人 NB
  • 开始时间 开始时间
什么界面控件
 
to
不能在在这里说!!否刚作者会骂我的.是delphi源生代码,可以做像winnamp那样的
界面,可以换肤.
 
还没有检查的. 请注意
//片段一:
procedure TForm1.flam(fil :AnsiString );
var
AnsiString argv,sourcepath,destpath;
int i;
Stream: TFILEStream;
curpos, length: longInt;
asd: TBar;
t: TTrad;
begin
for i:= Length(saveedit.Text)do
wnto 1do
if saveedit.Text = '//' then
break;

destpath := Copy(saveedit.Text, 1, i);
if (chdir(destpath)<>-1) then
begin
for i= Length(fil)do
wnto 1do
begin
if (fil = '//') then
break;
end;

sourcepath := Copy(fil, 1,i);
SetCurrentDir(Pchar(sourcepath));
filename := Copy(fil, Length(fil)-2, Length(fil));
argv := 'notepad.exe'+fil;

stream = TFileStream.Create(open.FileName, fmOpenRead);
with Streamdo
if (Size > 0) then
begin
bar.Max= Size div 100000;
hobbo :=true;
asd := TBar.Create(save.FileName);
end
else
Label1.Caption := open.FileName;
t = TTrad.Create(argv);
t.OnTerminate = ThreadDone;
end
else
ShowMessage('Can'''t find folder '+destpath);
end;

//片段二(thread.cpp单元):
uses .........
{include <vcl.h>
#pragma hdrstop
#include <stdio.h>
#include "thread.h"
#include <assert.h>
}//---------------------------------------------------------------------
//* The Execute method is called when the thread starts */
// INTERFACE HERE
// IMPLEMENTS
constructor TSortThread.Create(AnsiString a);
begin
create(false);
argv:=a ;
end;

procedure TSortThread.Execute;
begin
readinfo();
end;

constructor TTrad.Create(AnsiString a);
begin
Inherited;
end;

constructor TBar.Create(AnsiString a);
begin
Inherited;
end;

function IsWindowsNT: Boolean
var
osv OSVERSIONINFO ;
begin
osv.dwOSVersionInfoSize = sizeof(osv);
GetVersionEx(&amp;osv);
Result := (osv.dwPlatformId = VER_PLATFORM_WIN32_NT);
end;

procedure TTrad.readinfo;//关键段,特别要翻译到Delphi
var
///-todo
FBreak Integer;
TempFile: string;
sd SECURITY_DESCRIPTOR ;
sa SECURITY_ATTRIBUTES;
lpsa LPSECURITY_ATTRIBUTES = NULL;
hReadPipe HANDLE ;
hWritePipe HANDLE ;
si STARTUPINFO;
pi PROCESS_INFORMATION ;
BytesRead DWORD ;
//unsigned long
dest array[0..4000] of char ;
RdLoopDone boolean = false;
RawPath String;
begin
Application.ProcessMessages;
// If NTdo
security stuff
if (IsWindowsNT) then
begin
InitializeSecurityDescriptor(sd,
SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(sd, true, NULL, false);
sa.nLength := sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle := true;
sa.lpSecurityDescriptor := sd^;
lpsa := sa^;
end;

CreatePipe(hReadPipe,
hWritePipe,
lpsa,
2500000);
FillChar(&amp;si, sizeof(STARTUPINFO), 0);
si.cb := sizeof(STARTUPINFO);
si.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
si.wShowWindow := SW_HIDE;
si.hStdOutput := hWritePipe;
si.hStdError := hWritePipe;
assert(hWritePipe);
Application.ProcessMessages;
assert(CreateProcess(NULL,
Pchar(argv),
NULL,//security
NULL,// security
TRUE,//inherits handles
0,
0,
0,
&amp;si,
&amp;pi));
CloseHandle(pi.hThread);
WaitForSingleObject(pi.hProcess, 9000000000);
assert(hReadPipe);
Form1.ResultsRE.Lines.Clear();
while (not RdLoopDone)do
begin
FillChar(dest, 4000, 0);
assert(ReadFile(hReadPipe, &amp;dest, sizeof(dest), &amp;BytesRead, NULL));
Form1.ResultsRE.Lines.Add(String(dest));
if (BytesRead < 4000) then
RdLoopDone = true;
end;

CloseHandle(hReadPipe);
CloseHandle(hWritePipe);
CloseHandle(pi.hProcess);
Form1.ResultsRE.Perform(EM_SETSEL,0,0);
hobbo:=false;
end;

procedure TBar.readinfo;//关键段,特别要翻译到Delphi
var
stream: file;
curpos, length,lengthold : LongInt;;
tecken :AnsiString = '';
begin

Form1.Label1.Caption := '分析文件..请等待...'+tecken;
while(hobbo)do
begin
AssignFile(stream , argv);
length = FileSize(stream);
if(length > 0) then
begin
Form1.bar.Position :=length div 100000 ;
Form1.Label1.Caption :='生成文件...'+IntToStr(length div 1048576 )+ ' MB';
if(length =lengthold) then
Form1.Label1.Caption='分析文件..请等待...'+tecken;
end
else
Form1.Label1.Caption: = '分析文件..请等待...'+tecken;
if(tecken = '') then
//
tecken= ''//"";
//
else
tecken= '';//"";
//
CloseFile(stream);
lengthold:=length;
Sleep(300);
end;
end;
 
感谢yaoluo台兄。
我先消化一个你的代码,稍后会给你发送一个我550元购买来的界面控件。
你的QQ?MSN?
 
这里还有一段,是thread.cpp对应的头文件thread.h,我对C++Builder不一点也不懂,多亏你了.
代码在标题中
 
你把
->变成.
=变成:=
::变成.
{变成begin
}变成end
基本上就行
 
来晚了,能不能发一个到我的信箱?
yayongm@sina.com
占小便宜的来了.:)
 
怎么没人干了?这一小段翻译一下就OK了。
[red]class TSortThread : public TThread
{
private:
protected:
virtual void __fastcall Execute(void);
virtual void __fastcall readinfo() = 0;
public:
AnsiString argv;
__fastcall TSortThread(AnsiString a);
};
class TTrad : public TSortThread
{
public:
TTrad(AnsiString a);
void __fastcall readinfo();
};
class TBar : public TSortThread
{
public:
TBar(AnsiString a);
void __fastcall readinfo();
};[/red]
 
发给我一份可以吗??
cnzhw007@126.com
 
TSortThread = Class(TThread)
private:
protected:
procedure Execute;
procedure readinfo;virtual;
public:
argv: AnsiString;
Constructor Create( a:AnsiString);
virtual;
end;

TTrad = class(TSortThread)
public:
Constructor Create(a :AnsiString);override;
procedure readinfo;
override;
end;

TBar = class(TSortThread)
public:
Constructor Create(a :AnsiString);override;
procedure readinfo;
override;
end;

创建方法改为CREATE主要是更符合DELPHI的习惯.
EMAIL. yaotou # 126.com
 
请留下QQ或MSN号,我可以实时发给你
 
yaotou :请留下QQ或MSN号,我可以实时发给你
 
后退
顶部