GetModuleFileName function Null safety kernel32

int GetModuleFileName (
  1. int hModule,
  2. Pointer<Utf16> lpFilename,
  3. int nSize
)

Retrieves the fully qualified path for the file that contains the specified module. The module must have been loaded by the current process.

DWORD GetModuleFileNameW(
  HMODULE hModule,
  LPWSTR  lpFilename,
  DWORD   nSize
);

Implementation

int GetModuleFileName(int hModule, Pointer<Utf16> lpFilename, int nSize) {
  final _GetModuleFileName = _kernel32.lookupFunction<
      Uint32 Function(IntPtr hModule, Pointer<Utf16> lpFilename, Uint32 nSize),
      int Function(int hModule, Pointer<Utf16> lpFilename,
          int nSize)>('GetModuleFileNameW');
  return _GetModuleFileName(hModule, lpFilename, nSize);
}