ATL建立COM服務時必須注意的問題
阿新 • • 發佈:2019-02-20
1:用ATL嚮導建立COM元件時,必須指定ProgID
2:ATL嚮導生成的RGS有BUG,必須手工新增一句
val AppID = s '%APPID%'
像下面這樣
HKCR { ProgIDMyInterface.1 = s 'CMyInterface Class' { CLSID = s '{5B91E508-D66E-4F27-A371-E0D5FC3AAA0B}' } ProgIDMyInterface = s 'CMyInterface Class' { CurVer = s 'ProgIDMyInterface.1' } NoRemove CLSID { ForceRemove {5B91E508-D66E-4F27-A371-E0D5FC3AAA0B} = s 'CMyInterface Class' { ProgID = s 'ProgIDMyInterface.1' VersionIndependentProgID = s 'ProgIDMyInterface' ForceRemove Programmable LocalServer32 = s '%MODULE%' { val ServerExecutable = s '%MODULE_RAW%' } val AppID = s '%APPID%' TypeLib = s '{E57E6FF7-264C-4753-8393-FF512A651C7B}' Version = s '1.0' } } }
否則,客戶端在使用CoCreateInstance建立服務形式的COM元件時會返回伺服器啟動失敗的詭異的問題