GetModuleFileName (coredll)
Last changed: Joseph Cooney-123.243.157.225

.
Summary

C# Signature:

[DllImport("coredll.dll", SetLastError=true)]
private static extern int GetModuleFileName(IntPtr hModule, StringBuilder lpFilename, int nSize);

VB Signature:

Declare Function GetModuleFileName Lib "coredll.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

Taken from OpenNETCF.Reflection.AssemblyEx

Tips & Tricks:

Please add some!

Sample Code:

class CoreDllWrapper
{
    [DllImport("coredll.dll", SetLastError = true)]
     public static extern int GetModuleFileName(IntPtr hModule, StringBuilder lpFilename, int nSize);
}

// Will write the current executable's complete path into exePath
StringBuilder exePath = new StringBuilder(1024);
int exePathLen = CoreDllWrapper.GetModuleFileName(IntPtr.Zero, exePath, exePath.Capacity);

Documentation