So far, I haven't found a way to detect the process ID of the w3wp.exe instance loaded by the application pool when the Web site launches a new one. I have seen some ShellExecute() approach but this only applies when you launch the application manually. By using its handle, it would then be possible to get the process ID. But, this is from a Web application. It is launched by IIS.
I have seem some interesting thing like this:
http://it.toolbox.com/blogs/coding-dotnet/drilling-info-about-aspnet-worker-process-10002But, this only work with IIS 5 compatability.