首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

有一段代码看不懂能否解释?多谢

2012-02-19 
有一段代码看不懂能否解释?谢谢.我在看一段代码(关于:控制台程序并且获得它的输出结果)时看到的不明白想请

有一段代码看不懂能否解释?谢谢.
我在看一段代码(关于:控制台程序并且获得它的输出结果)时看到的不明白
想请教各位.谢谢!
procedure   TForm1.InitConsole;
var
    Security:   TSecurityAttributes;
    start:   TStartUpInfo;
begin
    with   Security   do   begin
        nlength   :=   SizeOf(TSecurityAttributes);
        binherithandle   :=   true;
        lpsecuritydescriptor   :=   nil;
    end;

    Createpipe(ReadOut,   WriteOut,   @Security,   0);
    Createpipe(ReadIn,   WriteIn,   @Security,   0);

    with   Security   do   begin
        nlength   :=   SizeOf(TSecurityAttributes);
        binherithandle   :=   true;
        lpsecuritydescriptor   :=   nil;
    end;

    FillChar(Start,   Sizeof(Start),   #0);
    start.cb   :=   SizeOf(start);
    start.hStdOutput   :=   WriteOut;
    start.hStdInput   :=   ReadIn;
    start.hStdError   :=   WriteOut;
    start.dwFlags   :=   STARTF_USESTDHANDLES   +
        STARTF_USESHOWWINDOW;
    start.wShowWindow   :=   SW_HIDE;

    CreateProcess(nil,
        PChar( 'cmd '),
        @Security,
        @Security,
        true,
        NORMAL_PRIORITY_CLASS,
        nil,
        nil,
        start,
        ProcessInfo)
end;
问题1:TSecurityAttributes和TStartUpInfo是什么?
(包括它们的属性(如:nlength,binherithandle,lpsecuritydescriptor,hStdOutput   等))
2.FillChar(Start,   Sizeof(Start),   #0);是什么意思有什么作用?



[解决办法]
1.
TSecurityAttributes是个记录类型, 等同于WinAPI中的_SECURITY_ATTRIBUTES结构体
TStartUpInfo也是个记录类型, 等同于WinAPI中的_STARTUPINFOA结构体
以上两个类型均在Windows单元中进行的声明。

2. FillChar(Start, Sizeof(Start), #0);
把Start变量(是个TStartUpInfo类型的变量)所占的空间全部填写上0。
[解决办法]
顶一个.
[解决办法]
关注
[解决办法]
MSDN -> CreateProcess
JF~

热点排行