<p>I have a delphi (Win32) web application that can run either as a CGI app, ISAPI or Apache DLL. I want to be able to generate a unique filename prefix (unique for all current requests at a given moment), and figure that the best way to do this would be to use processID (to handle CGI mode) as well as threadID (to handle dll mode).</p>

<p>How would I get a unique Process ID and Thread ID in Delphi?</p>

<p>Will these be unique in a Multi-Core/Multi-Processor situation (on a single webserver machine)?</p>

<p><em>Edit: please note that I was advised against this approach, and thus the accepted answer uses a different method to generate temporary filenames</em></p>

Could you not use a
GUID
instead?
Edit: Should have said first time around, check out the following two functions
```
```
CreateGuid
GuidToString
```
```