public unsafe static IEnumerable <PhysicalStoreInformation> EnumeratePhysicalStores(SystemStoreLocation location, string systemStoreName) { var info = new List <PhysicalStoreInformation>(); GCHandle infoHandle = GCHandle.Alloc(info); fixed(char *namePointer = systemStoreName) { try { // To lookup system stores in an alternate location you need to set CERT_SYSTEM_STORE_RELOCATE_FLAG // and pass in the name and alternate location (HKEY) in pvSystemStoreLocationPara. var callBack = new CertEnumPhysicalStoreCallback(PhysicalStoreEnumeratorCallback); Direct.CertEnumPhysicalStore( pvSystemStore: (IntPtr)namePointer, dwFlags: (uint)location, pvArg: GCHandle.ToIntPtr(infoHandle), pfnEnum: callBack); } finally { infoHandle.Free(); } } return(info); }
public static extern bool CertEnumPhysicalStore( [In, MarshalAs(UnmanagedType.LPWStr)] string pvSystemStore, [In] uint dwFlags, [In] IntPtr pvArg, [In] CertEnumPhysicalStoreCallback pfnEnum);
public static extern bool CertEnumPhysicalStore( IntPtr pvSystemStore, uint dwFlags, IntPtr pvArg, CertEnumPhysicalStoreCallback pfnEnum);