Skip to content

Instantly share code, notes, and snippets.

@Criteo-dotnet-blog
Created November 13, 2018 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Criteo-dotnet-blog/34a7651872572add94608204060c16d8 to your computer and use it in GitHub Desktop.
Save Criteo-dotnet-blog/34a7651872572add94608204060c16d8 to your computer and use it in GitHub Desktop.
private readonly StringBuilder _baseNameBuilder = new StringBuilder(1024);
public static string GetProcessNameNative(Process p)
{
_baseNameBuilder.Clear();
if (GetModuleFileNameEx(p.SafeHandle, IntPtr.Zero, _baseNameBuilder, _baseNameBuilder.Capacity) == 0)
{
_baseNameBuilder.Append("???");
}
return _baseNameBuilder.ToString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment