Registering DLL on windows mobile 6

扶醉桌前 提交于 2019-12-13 07:24:30

问题


I have a DLL file that contains an ActiveX control that I need to register it programmatically by code. here is the code I am using to register that DLL file but it keeps giving me "The system cannot find the file specified" when calling the Start method, And I do not know why regsvrce.exe is not found, should I change current directory or something, please help.

public static void registerDLL(string dllPath)
    {
        try
        {
            //'/s' : indicates regsvr32.exe to run silently.
            string fileinfo = "\"" + dllPath + "\"";

            Process reg = new Process();
            reg.StartInfo.FileName = "regsvrce.exe";
            reg.StartInfo.Arguments = fileinfo;
            reg.StartInfo.UseShellExecute = false;
            reg.Start();
            reg.WaitForExit();
            reg.Close();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

回答1:


Windows CE does not understand or support relative paths. So first, you have to ensure regsvrce.exe exists on the platform (it's not a given that it will, in fact it's pretty common for it to not exist) and you must fully qualify the path to it:

reg.StartInfo.FileName = @"\Windows\regsvrce.exe";

If it doesn't exist (or even if it does) you could easily do the same thing regsvrce.exe does, which is to call DllRegisterServer by simply P/Invoking LoadLibrary and calling the method directly.



来源:https://stackoverflow.com/questions/20299229/registering-dll-on-windows-mobile-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!