{"id":406,"date":"2009-05-21T12:38:00","date_gmt":"2009-05-21T04:38:00","guid":{"rendered":""},"modified":"2013-11-17T19:18:35","modified_gmt":"2013-11-17T11:18:35","slug":"delphi%e5%ae%9e%e7%8e%b0u%e7%9b%98%e5%8a%a0%e5%af%86%e7%8b%97%e5%8e%9f%e5%88%9b","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/406.html","title":{"rendered":"Delphi\u5b9e\u73b0U\u76d8\u52a0\u5bc6\u72d7[\u539f\u521b]"},"content":{"rendered":"<p>\u6548\u679c\uff0c\u53ea\u6709\u5f53\u6307\u5b9aU\u76d8\u63d2\u5165\u624d\u80fd\u6253\u5f00\u8be5\u7a0b\u5e8f\u3002\u8be5U\u76d8\u7684\u786c\u4ef6\u5e8f\u5217\u53f7\u4f5c\u4e3a\u89e3\u5bc6\u7684\u5bc6\u5319\u3002\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\r\nprocedure TForm1.GetDiskKey;\r\nconst\r\n     drivers:array&#x5B;0..25] of string=('A:\\','B:\\','C:\\','D:\\','E:\\','F:\\','G:\\','H:\\','I:\\','J:\\','K:\\','L:\\','M:\\','N:\\','O:\\','P:\\','Q:\\','R:\\','S:\\','T:\\','U:\\','V:\\','W:\\','X:\\','Y:\\','Z:\\');\r\nvar  i,sresult:integer;\r\n     isKey:boolean;\r\nbegin\r\n  isKey := false;\r\nfor I := 0 to 25 do\r\n  begin\r\n  sresult:=getdrivetype(pchar(drivers&#x5B;i]));\r\n  if (sresult=drive_removable) then\r\n  begin\r\n    if  (GetDiskID(PWidechar(drivers&#x5B;i]))='876986194') then\r\n    begin\r\n    isKey := true;\r\n    break;\r\n    end;\r\n  end;\r\n  end;\r\nif not isKey then   Application.Terminate;\r\nend;\r\n<\/pre>\n<p>\u5176\u4e2d\u5305\u542b\u6709GetDiskID\u51fd\u6570\u7684\u5355\u5143<\/p>\n<p>\u4f7f\u7528\u65b9\u6cd5\uff0c\u76f4\u63a5\u5728FormCreate\u6216OnCanResize\u6216OnActivate\u4e8b\u4ef6\u4e2d\u52a0\u4e0a\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>Form1.GetDiskKey<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6548\u679c\uff0c\u53ea\u6709\u5f53\u6307\u5b9aU\u76d8\u63d2\u5165\u624d\u80fd\u6253\u5f00\u8be5\u7a0b\u5e8f\u3002\u8be5U\u76d8\u7684\u786c\u4ef6\u5e8f\u5217\u53f7\u4f5c\u4e3a\u89e3\u5bc6\u7684\u5bc6\u5319\u3002\u4ee3\u7801\u5982\u4e0b\uff1a procedure TF [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-406","post","type-post","status-publish","format-standard","hentry","category-code_related"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=406"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/406\/revisions"}],"predecessor-version":[{"id":4758,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/406\/revisions\/4758"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}