GetServiceHandle in Mobile 2003 (VS2005)

Hi Alls,
I try to use some functions like GetServiceHandle, ActivateService to manage service in Mobile 2003 but there is the complier error :
error C3861: 'GetServiceHandle': identifier not found
The <service.h> is included in project

Thanks


Answer this question

GetServiceHandle in Mobile 2003 (VS2005)

  • Jose Simoes

    OK, the suggestion I got was to use CreateFile/DeviceIoControl instead. GetServiceHandle() is deprecated and shouldn't be used.

    Take a look at this blog entry:

    http://blogs.msdn.com/cenet/archive/2005/06/08/426850.aspx

    Also, see the documentation at:

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/wcecomm5/html/wce50conactivatingaserviceprogrammatically.asp

    Does this help


  • Mintu

    I realize this thread is a few months old, but I still have a question about it. I need to call DeregisterService(). According to the online (most current) MSDN documentation, it specifically states NOT to use CreateFile() to get the handle for DeregisterService(). http://msdn.microsoft.com/library/default.asp url=/library/en-us/wcecomm5/html/wce50lrfgetservicehandle.asp

    The documentation also says that the OSVersion is Windows CE.NET 4.0 or later, so my assumption is the SDK header for the PPC 2003 SDK service.h is incorrect.

    What is the thought process for the appropriate use of this API

    Thanks,

    Steve


  • Svunsson

    Thanks,
    I tested it, it is OK for me
    @+

  • Sagan33

    So,
    One guy spoke me about this solution

    typedef HANDLE Register_Service( LPCWSTR lpszType, DWORD dwIndex, LPCWSTR lpszLib,DWORD dwInfo);
    typedef HANDLE Activate_Service(LPCWSTR lpszDevKey, DWORD dwClientInfo);

    ...
    HINSTANCE hDLL = ::LoadLibrary(_T("coredll.dll"));
    if(!hDLL)
    {
    int error = GetLastError();
    return 0;
    }
    Register_Service * RegisterService = (Register_Service *)::GetProcAddress(hDLL, _T("RegisterService"));
    Activate_Service * ActivateService = (Activate_Service *)::GetProcAddress(hDLL, _T("ActivateService"));

    ...

    It is safe normal solution


  • penguinman007

    Steve:

    Unfortunately this is a goof up in the docs. You need to keep using GetServiceHandle() for DeregisterService(). But only use it for DeregisterService (don't use it for ServiceIoControl). Hope this helps.

    -Mel


  • sailorscott

    Glad to help.
  • Joel Brabant

    You will be accessing an undocumented API this way. This may work in the short term but can break your app in future versions of the OS. So it is niether safe nor normal. However, if your app only has to run on WM2003, it might be an acceptable workaround for you.

    I don't know the exact details of this API but I've contacted some developers within Microsoft who might be able to help. We should have some answer for you within a day or two. Thanks for your patience.

    Mel Sampat
    Program Manager, Microsoft
    This posting is provided "AS IS" with no warranties, and confers no rights.


  • hsaelens

    Thanks for your reply,
    My project target only WM2003.

    @+

  • mikn

    It seems like the GetServiceHandle API only compiles with the WM 5.0 SDK. I'm not sure why but I can try and find out if there's a workaround. Is your project targeting only WM2003 or 5.0 as well

    --
    Mel Sampat
    Program Manager, Microsoft
    This posting is provided "AS IS" with no warranties, and confers no rights.


  • GetServiceHandle in Mobile 2003 (VS2005)