internal static List<string> GetStoreNamesAtLocation(StoreLocation location) { NativeMethods.CertStoreFlags certStoreFlag = NativeMethods.CertStoreFlags.CERT_SYSTEM_STORE_CURRENT_USER; StoreLocation storeLocation = location; switch (storeLocation) { case StoreLocation.CurrentUser: { certStoreFlag = NativeMethods.CertStoreFlags.CERT_SYSTEM_STORE_CURRENT_USER; break; } case StoreLocation.LocalMachine: { certStoreFlag = NativeMethods.CertStoreFlags.CERT_SYSTEM_STORE_LOCAL_MACHINE; break; } } NativeMethods.CertEnumSystemStoreCallBackProto certEnumSystemStoreCallBackProto = new NativeMethods.CertEnumSystemStoreCallBackProto(Crypt32Helpers.CertEnumSystemStoreCallBack); List<string> strs = new List<string>(); lock (Crypt32Helpers.staticLock) { Crypt32Helpers.storeNames.Clear(); NativeMethods.CertEnumSystemStore(certStoreFlag, IntPtr.Zero, IntPtr.Zero, certEnumSystemStoreCallBackProto); foreach (string storeName in Crypt32Helpers.storeNames) { strs.Add(storeName); } } return strs; }
internal static List <string> GetStoreNamesAtLocation(StoreLocation location) { NativeMethods.CertStoreFlags certStoreFlag = NativeMethods.CertStoreFlags.CERT_SYSTEM_STORE_CURRENT_USER; StoreLocation storeLocation = location; switch (storeLocation) { case StoreLocation.CurrentUser: { certStoreFlag = NativeMethods.CertStoreFlags.CERT_SYSTEM_STORE_CURRENT_USER; break; } case StoreLocation.LocalMachine: { certStoreFlag = NativeMethods.CertStoreFlags.CERT_SYSTEM_STORE_LOCAL_MACHINE; break; } } NativeMethods.CertEnumSystemStoreCallBackProto certEnumSystemStoreCallBackProto = new NativeMethods.CertEnumSystemStoreCallBackProto(Crypt32Helpers.CertEnumSystemStoreCallBack); List <string> strs = new List <string>(); lock (Crypt32Helpers.staticLock) { Crypt32Helpers.storeNames.Clear(); NativeMethods.CertEnumSystemStore(certStoreFlag, IntPtr.Zero, IntPtr.Zero, certEnumSystemStoreCallBackProto); foreach (string storeName in Crypt32Helpers.storeNames) { strs.Add(storeName); } } return(strs); }
internal static extern bool CertEnumSystemStore( NativeMethods.CertStoreFlags Flags, IntPtr notUsed1, IntPtr notUsed2, NativeMethods.CertEnumSystemStoreCallBackProto fn);