public static bool format(char letter, String fileSystemName, UInt32 allocationSize, String label) { bool result = false; string helperDLLName = "misterhelper.dll"; EmbeddedDll.ExtractEmbeddedDlls(helperDLLName); IntPtr hDll = EmbeddedDll.LoadDll(helperDLLName); if (hDll != IntPtr.Zero) { IntPtr pAddrFormatFunction = GetProcAddress(hDll, "Format"); FormatDelegate formatDelegate = (FormatDelegate)Marshal.GetDelegateForFunctionPointer(pAddrFormatFunction, typeof(FormatDelegate)); result = formatDelegate(letter.ToString(), fileSystemName, allocationSize, label); FreeLibrary(hDll); } /* * Call from direct reference * { * Format(letter.ToString(), fileSystemName, allocationSize, label); * } */ return(result); }
public static bool formatVolume(String volumeID, String fileSystemName, UInt32 allocationSize, String label) { bool result = false; string helperDLLName = "misterhelper.dll"; EmbeddedDll.ExtractEmbeddedDlls(helperDLLName); IntPtr hDll = EmbeddedDll.LoadDll(helperDLLName); if (hDll != IntPtr.Zero) { IntPtr pAddrFormatFunction = GetProcAddress(hDll, "FormatVolume"); if (!IntPtr.Equals(pAddrFormatFunction, IntPtr.Zero)) { FormatVolumeDelegate formatDelegate = (FormatVolumeDelegate)Marshal.GetDelegateForFunctionPointer(pAddrFormatFunction, typeof(FormatVolumeDelegate)); result = formatDelegate(volumeID, fileSystemName, allocationSize, label); } else { Logger.Error("Unable to resolve 'FormatVolume' function in misterhelper.dll"); } FreeLibrary(hDll); } else { Logger.Error("Unable to load 'misterhelper.dll'"); } /* * Call from direct reference * { * Format(letter.ToString(), fileSystemName, allocationSize, label); * } */ return(result); }