我是个Delphi新手,看大家的问题时,经常不明白。
好象大家是调用了API函数。我对控件的简单使用掌握的还可以,对于API函数就一点也不懂了。
我没有什么分,求大家给小弟指条路。谢谢

解决方案 »

  1.   

    可是我对其中的参数不明白啊。
    我想学习API该从哪步开始啊。
    谢谢以上两个大哥的指教。
      

  2.   

    开始看着头大是非常非常正常的,
    坚持下去继续看,继续用,慢慢就发现不那么复杂了,容易多了。
    学习的时候主要是看SDK帮助,还可以学英语,一举两得,呵呵
      

  3.   

    买本书把
    有专门讲api的书
      

  4.   

    推薦你一本書中國電力出版社的 《Delphi win32 核心API參考》
    John Ayres 著
    陳悅 翻譯
    公認最強的Delphi書籍
      

  5.   

    《Delphi win32 核心API參考》
    我也觉得这本书不错~~~~
      

  6.   

    多学多用多练多看,我是从exitwindowsex这个函数开始的,那时候还是用vb写了一个关机程序,主要是那时候晚上和同学打cs经常会忘记时间,然后电脑被学校断电,然后就自己写了那么个小玩意,用来在掐电前5分钟关机,呵呵。主要是把api里的参数能与delphi的对上来,搞清楚类型就不难了
      

  7.   

    你 能写 出 API 底层 是什么样吗?
      

  8.   

    fenger8293(深爱着兰) :
       能否把你的关机的示例给我们看一下!
    谢谢!
      

  9.   

    program ExitNt; Uses
      Windows;
    {$R *.RES}function SetPrivilege(sPrivilegeName : string;bEnabled : boolean ): boolean;
    var
      TPPrev,
      TP : TTokenPrivileges;
      Token : THandle;
      dwRetLen : DWord;
    begin
      Result := False;
      //opens the access token associated with a process.
      OpenProcessToken(
      GetCurrentProcess, //handle to process
      TOKEN_ADJUST_PRIVILEGES //Required to change the privileges specified in an access token.
      or TOKEN_QUERY, //Required to query the contents of an access token.
      Token);
      TP.PrivilegeCount := 1;
      //retrieves the locally unique identifier (LUID) used on a specified system to
      //locally represent the specified privilege name.
      if( LookupPrivilegeValue(
      Nil, //attempts to find the privilege name on the local system.
      PChar( sPrivilegeName ), // address of string specifying the privilege
      TP.Privileges[ 0 ].LUID ) // address of locally unique identifier
      )then
      begin
        if( bEnabled )then //Give this privileges
        begin
          TP.Privileges[ 0 ].Attributes := SE_PRIVILEGE_ENABLED;
        end
        else
        begin //NOT Give this privileges
          TP.Privileges[ 0 ].Attributes := 0;
        end;
          dwRetLen := 0;
        //enables or disables privileges in the specified access token.
        Result := AdjustTokenPrivileges(
        Token, // handle to token that contains privileges
        False, //modifies privileges
        TP, // pointer to new privilege information
        SizeOf( TPPrev ), // size, in bytes, of the TPPrev buffer
        TPPrev, // receives original state of changed privileges
        dwRetLen // receives required size of the TPPrev buffer
        );
      end;
      CloseHandle(Token);
    end;
    function WinExitInNT( iFlags : integer ) : boolean;
    begin
      Result := True;
      if( SetPrivilege( 'SeShutdownPrivilege', True ) )then
      begin
        if( not ExitWindowsEx( iFlags, 0 ) )then
        begin
        Result := False;
        end;
      SetPrivilege( 'SeShutdownPrivilege', False )
      end
      else
      begin
    // handle errors...
      Result := False;
      end;
    end;
    begin
      WinExitInNT(EWX_SHUTDOWN+EWX_POWEROFF);
    end.