Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "GetModuleFileName" in [All]

psapi

.

Used in conjuction with GetModuleFileNameEx:

.

            GetModuleFileNameEx(p.Handle, hMods[i], strbld, (uint)(strbld.Capacity));

.

static extern uint GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, [Out] StringBuilder lpBaseName, [In] [MarshalAs(UnmanagedType.U4)] int nSize);

.

Public Shared Function GetModuleFileNameEx(ByVal hProcess As IntPtr, ByVal hModule As IntPtr, <Out()> ByVal lpBaseName As StringBuilder, <[In]()> <MarshalAs(UnmanagedType.U4)> ByVal nSize As Integer) As UInteger

.

static extern uint GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, [Out] StringBuilder lpBaseName, uint nSize);

.

            GetModuleFileNameEx(p.Handle, hMods[i], strbld, (uint)(strbld.Capacity));

.
Documentation
[GetModuleFileNameEx] on MSDN
.

This can be used in place of the GetModuleFileName call, which doesn't work on processes that haven't been loaded by the current one.

.

I found this to be more comprehensive than GetModuleFileNameEx. Didnt need to enumerate windows or modules

kernel32

.
Summary
.

public static extern uint GetModuleFileName

.

Public Function GetModuleFileName(<[In]()> ByVal hModule As IntPtr, <Out()> ByVal lpFilename As StringBuilder, <[In]()> <MarshalAs(UnmanagedType.U4)> ByVal nSize As Integer) As UInteger

.

If you want to use GetModuleFilename to retrieve the path the current executable was started from, you should instead consider using System.Windows.Forms.Application.StartupPath. This is a wrapper around GetModuleFilename, so it probably does exactly what you want.

.

        DllFuntions.GetModuleFileName(IntPtr.Zero, fileName, fileName.Capacity);

.
Documentation
[GetModuleFileName] on MSDN

coredll

.

To locate the file for a module that was loaded by current process, use the GetModuleFileName function.

.

static extern int GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, StringBuilder lpFilename, int nSize);

.

Declare Function GetModuleFileNameEx Lib "coredll.dll" (ByVal hProcess As IntPtr, ByVal hModule As IntPtr, ByVal lpFileName As System.Text.StringBuilder, ByVal nSize As Int32) As Int32

.
Documentation
[GetModuleFileNameEx] on MSDN
.

To locate the file for a module that was loaded by current process, use the GetModuleFileName function.

.

static extern int GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, StringBuilder lpFilename, int nSize);

.

Declare Function GetModuleFileNameEx Lib "coredll.dll" (ByVal hProcess As IntPtr, ByVal hModule As IntPtr, ByVal lpFileName As System.Text.StringBuilder, ByVal nSize As Int32) As Int32

.
Documentation
[GetModuleFileNameEx] on MSDN

 
Access PInvoke.net directly from VS: