CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2002
    Location
    Italy
    Posts
    90

    COM exe registration problem......

    Hi everibody, I've the following problem, I'm trying to register on my machine a COM exe with the following command C:\myComSrv.exe /RegServer, I've noticed in Task Manager that myComSrv start but unfortunately the instance still alive since I kill it manually.
    Can someone suggest me a way to understand this strange behaviour?
    Thank you everybody in advance

  2. #2
    Join Date
    Apr 2000
    Location
    Boston
    Posts
    124

    Re: COM exe registration problem......

    The call to register your server should be in your _tWinMain function (in myComSrv.cpp). The code should look like this:

    Code:
    extern "C" int WINAPI _tWinMain(HINSTANCE hInstance, 
    {
        //......
        BOOL bRun = TRUE;
        LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens);
        while (lpszToken != NULL)
        {
            if (lstrcmpi(lpszToken, _T("UnregServer"))==0)
            {
                _Module.UpdateRegistryFromResource(IDR_myComSrv, FALSE);
                nRet = _Module.UnregisterServer(TRUE);
                bRun = FALSE;
                break;
            }
            if (lstrcmpi(lpszToken, _T("RegServer"))==0)
            {
                _Module.UpdateRegistryFromResource(IDR_myComSrv, TRUE);
                nRet = _Module.RegisterServer(TRUE);
                bRun = FALSE;
                break;
            }
            lpszToken = FindOneOf(lpszToken, szTokens);
        }
        if (bRun)
        {
            _Module.StartMonitor();
           //......
        }
        _Module.Term();
        CoUninitialize();
        return nRet;
    }
    I would guess the bRun is not being set to FALSE, so your RegServer code is not called. Place a breakpoint in this code and run the exe from the debugger. In your Project Settings->Debug set the program arguments to /RegServer (it might be as simple as the / in /RegServer).

  3. #3
    Join Date
    Nov 2002
    Location
    Italy
    Posts
    90

    Re: COM exe registration problem......

    Thank you but unfortunately bRun is FALSE, I've noticed my application exit from _tWinMain but in task manager the instance still alive

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured