本帖最后由 jyswjjgdwtdtj 于 2025-3-22 15:49 编辑
回复 3# 小白龙
powershell获取的clsid不是com组件真的clsid
比如wshshell的clsid是72C24DD5-D70A-438B-8A42-98424B88AFB8 但powershell给出了41904400-be18-11d3-a28b-00104bd35090
更正一下 这样才能获取到progid- $s=@'
- using System;
- using System.Runtime.InteropServices;
-
- namespace ns
- {
- public class com
- {
- [DllImport("ole32.dll")]
- static extern int ProgIDFromCLSID([In] ref Guid clsid, [MarshalAs(UnmanagedType.LPWStr)] out string lplpszProgID);
- public static string Getprogid(string clsid)
- {
- string progId = "";
- Guid guid = new Guid(clsid);
- ProgIDFromCLSID(ref guid, out progId);
- return progId;
- }
- }
- }
- '@
- add-type -typedefinition $s
- [ns.com]::Getprogid("{72C24DD5-D70A-438B-8A42-98424B88AFB8}")
复制代码
|