{"id":223,"date":"2007-05-12T17:12:52","date_gmt":"2007-05-12T15:12:52","guid":{"rendered":" http:\/\/www.nsonic.de\/blog\/2007\/05\/getting-the-temp-path-of-the-system\/"},"modified":"2007-05-12T17:12:54","modified_gmt":"2007-05-12T15:12:54","slug":"getting-the-temp-path-of-the-system","status":"publish","type":"post","link":"https:\/\/www.nsonic.de\/blog\/2007\/05\/getting-the-temp-path-of-the-system\/","title":{"rendered":"Getting the Temp Path of the System"},"content":{"rendered":"<p><em>You know, every PC can have a different location where the user likes to store temporary files. But Windows has an API function to retrieve this directory name&#8230; and you can let Windows create a new temp-Filename that you can use.<br \/>\n(thanks to Rick Rogers (TeamB) for posting this hint)<br \/>\n<\/em><\/p>\n<p>Use the GetTempPath and GetTempFileName Windows API routines, like this (assuming 32-bit Delphi long strings):<\/p>\n<p>[code lang=&#8221;delphi&#8221;]procedure TForm1.Button1Click(Sender: TObject);<br \/>\nvar TempPath: string;<br \/>\n     TempFileName: string;<br \/>\n     Return : Integer;<br \/>\nbegin<br \/>\n  SetLength(TempPath, MAX_PATH);<br \/>\n  if GetTempPath(MAX_PATH, PChar(TempPath)) = 0 then<br \/>\n    raise Exception.Create(&#8216;error getting temp path&#8217;); <\/p>\n<p>  SetLength(TempFileName, MAX_PATH);<br \/>\n  if GetTempFileName(PChar(TempPath), &#8216;pre&#8217;, 0, PChar(TempFileName)) = 0 then<br \/>\n    raise Exception.Create(&#8216;error getting temp filename&#8217;); <\/p>\n<p>  TempFileName := Trim(TempFileName);<br \/>\n  ShowMessage(TempFileName);<br \/>\nend;[\/code]<\/p>\n<p>[tags]Delphi, System, Files[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You know, every PC can have a different location where the user likes to store temporary files. But Windows has an API function&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[11],"tags":[75,112,113],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p71Tml-3B","_links":{"self":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/223"}],"collection":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/comments?post=223"}],"version-history":[{"count":0,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/223\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/media?parent=223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/categories?post=223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/tags?post=223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}