开发者

Issue with .INF file for registering ActiveX

开发者 https://www.devze.com 2022-12-09 17:15 出处:网络
I have made an INF file, its contents are as follows [version] Signature=\"$CHICAGO$\" AdvancedINF=2.0 [Add.Code]

I have made an INF file, its contents are as follows

[version]
Signature="$CHICAGO$"
AdvancedINF=2.0

[Add.Code]
MyControl.dll=MyControl.dll


; Now installing the ActiveX
[MyControl.dll]
file-win32-x86=thiscab
clsid={05B7BC83-FCA1-452d-9D33-193784FEC637}
FileVersion=1,0,0,1
RegisterServer=yes

but the Control is not registered after Internet Explorer has finished installation, and each time I press F5 to refresh the webpage, my browser shows the Installation prompt.?? which means that it is not installed in my machine. And when I run regasm /tlb /codebase MyControl.dll command it starts working fine... I have written my ActiveX control in C# and here are registering function

[ComRegisterFunction()]
        public static void 开发者_开发百科RegisterClass ( string key )
        {
            // Strip off HKEY_CLASSES_ROOT\ from the passed key as I don't need it
            StringBuilder   sb = new StringBuilder ( key ) ;

            sb.Replace(@"HKEY_CLASSES_ROOT\","") ;
            // Open the CLSID\{guid} key for write access
            RegistryKey k   = Registry.ClassesRoot.OpenSubKey(sb.ToString(),true);

            // And create   the 'Control' key - this allows it to show up in
            // the ActiveX control container
            RegistryKey ctrl = k.CreateSubKey   ( "Control" ) ;
            ctrl.Close ( ) ;

            // Next create the CodeBase entry   - needed if not string named and GACced.
            RegistryKey inprocServer32 = k.OpenSubKey   ( "InprocServer32" , true ) ;
            inprocServer32.SetValue (   "CodeBase" , Assembly.GetExecutingAssembly().CodeBase ) ;
            inprocServer32.Close ( ) ;
                // Finally close the main   key
            k.Close (   ) ;
            //MessageBox.Show("Registered");
        }

Please help me out that why RegisterServer=yes is not calling this function, and I have to call it manually using regasm /tlb /codebase MyControl.dll command?


There's a bit more detail on how to implement Ummar's workaround in the Downloading C# ActiveX Components through CAB File article on CodeProject

(Disclaimer: I haven't tried it - only found the article a week after I resorted to using ATL and C++ :-( ).


When the CAB content specified with RegisterServer=yes is registered, it uses regsvr32. Your C# assembly requires regasm, therefore you need an additional mechanism to enforce regasm. The suggested way is with an msi package, which will give the user a way to uninstall your component.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号