Tech Off Thread

16 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

WIA

Back to Forum: Tech Off
  • User profile image
    crupib

    I am looking for a simple working example in wia to use the following function: pWiaDevMgr->RegisterEventCallbackCLSID

    I need my program to be called when a camera is plugged in and the button is clicked.

    I use WIA_EVENT_ITEM_CREATED. This works with RegisterEventCallbackInterface.

    This will call my program (calls ImageEventCallback). This works, but the application has to be running. I want my program to be called even if it is not running. I understand if I use RegisterEventCallbackCLSID, this will do what I need. Can anyone help me.

  • User profile image
    spivonious
  • User profile image
    crupib

    @spivonious:No it is not. The links you sent me are not working examples of the these functions.

    I can't find any examples anywhere.

  • User profile image
    DCMonkey

    @crupib:

    I understand why this won't be any more helpful than the API docs but I couldn't resist:

    Example

     

  • User profile image
    crupib

    No it is no help. I am just wondering if any one has done this.

    I need an example of how this all works together.

    Does anyone have an working example. I can read the doc as bad as it is.

    It does show how to use it. None of the SDK examples use this function:

    RegisterEventCallbackCLSID

    So I need a little help.

  • User profile image
    Charles

    Is your application a registered COM component, per the documentation? If not, then you can't use this method. You would need to use this one.
    C

  • User profile image
    RhymesWith​Orange

    We need some more info as to your overall scenario. Can you please elaborate?

  • User profile image
    crupib

    OK, I am using the getimage sample from the sdk samples. I want to change the

    the following with:

     hr = pWiaDevMgr->RegisterEventCallbackInterface(
            0,
            NULL,
            &WIA_EVENT_DEVICE_DISCONNECTED,
            this,
            &m_pDisconnectEventObject
        );

    I need the to know what information needs to be put into the

    HRESULT RegisterEventCallbackCLSID(
    [in]  LONG lFlags,
    [in]  BSTR bstrDeviceID,
    [in]  const GUID *pEventGUID,
    [in]  const GUID *pClsID,
    [in]  BSTR bstrName,
    [in]  BSTR bstrDescription,
    [in]  BSTR bstrIcon
    );

    Function.
    How do I set up a pClsID?
    This is the information I used. It does not work.
    I found this on the internet:

    IWiaDevMgr *pWiaDevMgr = NULL;
    HRESULT hr;

    ::CoInitialize(NULL);

    if( (hr = ::CoCreateInstance(CLSID_WiaDevMgr, NULL, CLSCTX_LOCAL_SERVER,
    IID_IWiaDevMgr, (void**)&pWiaDevMgr )) == S_FALSE)
    {
    return hr;
    }
    CLSID appId ={0,};
    // will a guid I generate be able to use in the following.

    if(CLSIDFromString(OLESTR("{DBFBB272-B295-44AF-932C-AF5DAF5FF901}"),&appId) != NOERROR)
    {
    }
    wchar_t pAppName[] = L"Sample01";
    wchar_t pArg[] = "what goes here the name of my executable?"
    wchar_t pIcon[] = L"test3, 0";
    wchar_t pAstrick[] = L"*";
    wchar_t pAppDescript[] = L"THIS SAMPLE PROGRAM";
    GUID guid = WIA_EVENT_ITEM_CREATED;

    hr = pWiaDevMgr->RegisterEventCallbackCLSID(WIA_REGISTER_EVENT_CALLBACK,
    SysAllocString(pAstrick),
    &guid,
    &appId,
    SysAllocString(pArg),
    SysAllocString(pAppDescript),
    SysAllocString(pIcon));
    if(FAILED(hr))
    {
    return hr;
    }



  • User profile image
    Charles

    You didn't answer the question: Is this a registered COM binary? You don't have to use this API unless it is... What OS are you using? If you are running Vista or 7, then use the WIA 2.0 API. The documentation is really clear about what the parameter types are.

    C

  • User profile image
    spivonious

    If your app is COM registered, then you know the CLSID for it. Check the registry.

    If it's not a COM application, you can't use this API.

  • User profile image
    crupib

    This is a com application. Where in the registry do I look.

    And no one is answering my questions. Please check the code in previous replies.

    This is not Vista it is XP.

  • User profile image
    spivonious

    @crupib: Search for your class name under HKEY_CLASSES_ROOT\CLSID\. The GUID that it's under is your CLSID.

  • User profile image
    crupib

    How to I link to events when a wia device produces them.

    Do I run the

    hr = pWiaDevMgr->RegisterEventCallbackCLSID(WIA_REGISTER_EVENT_CALLBACK,
    SysAllocString(pAstrick),
    &guid,
    &appId,
    SysAllocString(pArg),
    SysAllocString(pAppDescript),
    SysAllocString(pIcon));
    Command as part of the register of the com object?
  • User profile image
    spivonious

    @crupib: I don't know. I'd run it as part of an installer. I'd imagine that you'd need to finish the COM registering before calling the method.

  • User profile image
    crupib

    I would like to thank everyone for your help.

    I had to learn a lot about com+, WIA, ATL, etc...

    I think I am almost there. I will upload the code after tonight.

    The summary of what I did was create a ATL exe which is a com+. It implements

    the WIA function. As part of the init of installing this com+. I added the WIA registration.

    It was late last night so I did not test. I will tonight. If it works woo hoo. If not I will

    as I already said upload my code.

  • User profile image
    crupib

    Where is the info for wia events stored in the registry?

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.