计算机二级DELPHI函数:WindowsAPI函数使用技巧

来源:计算机等级考试    发布时间:2012-08-29    计算机等级考试视频    评论


  begin
  V1 := dwFileVersionMS shr 16;
  V2 := dwFileVersionMS and $FFFF;
  V3 := dwFileVersionLS shr 16;
  V4 := dwFileVersionLS and $FFFF;
  end;
  FreeMem(VerInfo, VerInfoSize);
  end;
  ------------------------------------------
  回答2
  If you want a component, check out TVersionInfoResource at
  delphi//">http://www.pobox.com/~bstowers/delphi/ in the My Stuff section. D1/D2/D3/C++B
  compatible, freeware with full source code and a small demo.
  And you can see the delphi//">http://www.aye.net/~bstowers/delphi/
  另一个component VersionInfo.zip
  防止程序运行多个例程?
  More than one instance of program?
  回答
  This is copied direct from my *.dpr file. You can work it for your own
  use.
  var
  hMutex : Thandle;
  WaitResult : word;
  BroadcastList : DWORD;
  begin
  MessageID := RegisterWindowMessage(/'Check For Choice Previous Inst/');
  // register a message to use later on
  hMutex := createMutex(nil,false,pchar(/'App_Choice/')); // grab a mutex
  handle
  WaitResult := WaitForSingleObject(hMutex,10); // wait to see
  if we can have exclusive use of the mutex
  if ( waitResult = WAIT_TIMEOUT ) then // if we can/'t then broadcast
  the message to make the owner of the mutex respond
  { request that the running application takes focus }
  begin
  BroadcastList := BSM_APPLICATIONS;
  BroadcastSystemMessage(
  BSF_POSTMESSAGE,@BroadcastList,MessageID,0,0); file://32 bit - broadcast the
  message to all apps - only a prev inst will hear it.
  end
  else
  begin
  { do the normal stuff}
  Application.Title := /'Choice Organics Purchase & Sales System/';
  Application.CreateForm(TMainForm, MainForm);
  Application.Run;
  ReleaseMutex(hMutex); // release the mutex as a politeness
  end;
  CloseHandle(hMutex); // close the mutex handle
  end.
  This goes in the MainForm
  procedure Tmainform.OnAppMessage(var Msg : TMsg ; Var Handled : Boolean);
  begin
  { If it/'s the special message then focus on this window}
  if Msg.Message = MessageID then // if we get the broadcast message from an
  another instance of this app that is trying to start up
  begin
  show;
  WindowState := wsMaximized;
  BringToFront;
  SetFocus;
  Handled := true;
  end;
  end;
  file://And this goes in the TMainForm.FormCreate ;-
  Application.OnMessage:= OnAppMessage;
  4.得到Win 95 的计算机名字?
  问 How can I learn Windows/'95 Machine Name?
  答function ComputerName : String;
  var
  CNameBuffer : PChar;
  fl_loaded : Boolean;
  CLen : ^DWord;
  begin
  GetMem(CNameBuffer,255);
  New(CLen);
  CLen^:= 255;
  fl_loaded := GetComputerName(CNameBuffer,CLen^);
  if fl_loaded then
  ComputerName := StrPas(CNameBuffer)
  else
  ComputerName := /'Unkown/';
  FreeMem(CNameBuffer,255);
  Dispose(CLen);
  end;
  7. 停止一个线程?
  问 Stop A Thread?
  回答
  You can Terminate your thread in two ways:
  1) Assign ThreadDone to OnTerminate when you create it.
  In the Execute method, exit when the terminated property is True.
  At the point where you want to stop, issue the Terminate method.
  2) Just call the Suspend method.
  After one of these steps you may free the thread.
  I hope the following snippets will help.
  // -------------------------------------------------------------- //
  interface

  2009年上半年全国计算机等级考试参考答案请进入计算机考试论坛

  2009年全国计算机等级考试报名信息汇总

  2009年NCRE考试有新变化

  2009年全国计算机等级考试大纲

  2009年上半年全国计算机二级考试试题及答案

  2009年上半年全国计算机等级考试试题答案汇总

上一页123下一页

视频学习

我考网版权与免责声明

① 凡本网注明稿件来源为"原创"的所有文字、图片和音视频稿件,版权均属本网所有。任何媒体、网站或个人转载、链接转贴或以其他方式复制发表时必须注明"稿件来源:我考网",违者本网将依法追究责任;

② 本网部分稿件来源于网络,任何单位或个人认为我考网发布的内容可能涉嫌侵犯其合法权益,应该及时向我考网书面反馈,并提供身份证明、权属证明及详细侵权情况证明,我考网在收到上述法律文件后,将会尽快移除被控侵权内容。

最近更新

社区交流

考试问答