private bool Init() { _hVaultCliDll = Kernel32.LoadLibrary("vaultcli.dll"); if (_hVaultCliDll == Kernel32.SafeLibraryHandle.Null) { Console.WriteLine("Cannot load vaultcli.dll library"); return(false); } _pVaultOpenVault = (VaultOpenVaultT)Marshal.GetDelegateForFunctionPointer( Kernel32.GetProcAddress(_hVaultCliDll, "VaultOpenVault"), typeof(VaultOpenVaultT)); _pVaultCloseVault = (VaultCloseVaultT)Marshal.GetDelegateForFunctionPointer( Kernel32.GetProcAddress(_hVaultCliDll, "VaultCloseVault"), typeof(VaultCloseVaultT)); _pVaultEnumerateItems = (VaultEnumerateItemsT)Marshal.GetDelegateForFunctionPointer( Kernel32.GetProcAddress(_hVaultCliDll, "VaultEnumerateItems"), typeof(VaultEnumerateItemsT)); _pVaultGetItem = Kernel32.GetProcAddress(_hVaultCliDll, "VaultGetItem"); _pVaultFree = (VaultFreeT)Marshal.GetDelegateForFunctionPointer( Kernel32.GetProcAddress(_hVaultCliDll, "VaultFree"), typeof(VaultFreeT)); if ((_pVaultOpenVault == null) || (_pVaultEnumerateItems == null) || (_pVaultCloseVault == null) || (_pVaultGetItem == IntPtr.Zero) || (_pVaultFree == null)) { Console.WriteLine("Cannot load vaultcli.dll functions"); return(false); } return(true); }
private static Image GetImageAtlasFromTheme(VisualTheme vs, Kernel32.SafeLibraryHandle hInstance) { var byteStream = vs.GetDiskStream(hInstance, 0, 0, 213); if (byteStream == null) { return(null); } using (var ms = new MemoryStream(byteStream)) { return(Image.FromStream(ms)); } }
public byte[] GetDiskStream(Kernel32.SafeLibraryHandle hInst, int partId, int stateId, int propId) { byte[] bytes; int bLen; var r = GetThemeStream(hTheme, partId, stateId, propId, out bytes, out bLen, hInst); if (r == 0) { return(bytes); } if ((uint)r != 0x80070490) { throw new InvalidOperationException("Bad GetThemeStream"); } return(null); }
private long NSS_Init(string configdir) { Kernel32.LoadLibrary(_mozillaPath + "mozcrt19.dll"); Kernel32.LoadLibrary(_mozillaPath + "nspr4.dll"); Kernel32.LoadLibrary(_mozillaPath + "plc4.dll"); Kernel32.LoadLibrary(_mozillaPath + "plds4.dll"); Kernel32.LoadLibrary(_mozillaPath + "ssutil3.dll"); Kernel32.LoadLibrary(_mozillaPath + "sqlite3.dll"); Kernel32.LoadLibrary(_mozillaPath + "nssutil3.dll"); Kernel32.LoadLibrary(_mozillaPath + "softokn3.dll"); _nss3 = Kernel32.LoadLibrary(_mozillaPath + "nss3.dll"); var pProc = Kernel32.GetProcAddress(_nss3, "NSS_Init"); var dll = (NssInitDelegate)Marshal.GetDelegateForFunctionPointer(pProc, typeof(NssInitDelegate)); return(dll(configdir)); }
public static extern HRESULT TaskDialog(HandleRef hwndParent, Kernel32.SafeLibraryHandle hInstance, string pszWindowTitle, string pszMainInstruction, string pszContent, TaskDialogCommonButtonFlags dwCommonButtons, IntPtr pszIcon, out int pnButton);