Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CreateHardwareEventMoniker

CreateHardwareEventMoniker

Scheduled Pinned Locked Moved C / C++ / MFC
csharpvisual-studiocomhelpannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    act_x
    wrote on last edited by
    #1

    I am using some code to develop an Autoplay handler based on this application note. http://msdn2.microsoft.com/en-us/library/bb776827.aspx As described in this article, I would want to enable or disable the Autoplay feature by using code like this . typedef HRESULT (*CREATEHARDWAREEVENTMONIKER)(REFCLSID clsid, LPCWSTR pszEventHandler, IMoniker **ppmoniker); HRESULT RegisterComponent(IUnknown* punk, DWORD* dpwToken) { HRESULT hr = E_FAIL; HINSTANCE hinstShSvcs = LoadLibrary(TEXT("shsvcs.dll")); if (hinstShSvcs) { CREATEHARDWAREEVENTMONIKER fct = (CREATEHARDWAREEVENTMONIKER)GetProcAddress(hinstShSvcs, "CreateHardwareEventMoniker"); if (fct) { IMoniker* pmoniker; **hr = fct(CLSID_App, TEXT("VideoCameraArrival"), &pmoniker);** if (SUCCEEDED(hr)) { IRunningObjectTable *prot; if (SUCCEEDED(GetRunningObjectTable(0, &prot))) { hr = prot->Register(ROTFLAGS_ALLOWANYCLIENT | ROTFLAGS_REGISTRATIONKEEPSALIVE, punk, pmoniker, &_dwRegisterROT); prot->Release(); } pmoniker->Release(); } CoRegisterClassObject(CLSID_App, static_cast<IClassFactory *>(this), CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &_dwRegisterClass; } FreeLibrary(hinstShSvcs); } return hr; } However I find that there is an exception occuring in this line hr = fct(CLSID_App, TEXT("VideoCameraArrival"), &pmoniker); The exception is as follows : Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention. I am debugging this on Visual Studio 2005 and have no clue as to why this is happenning . help is appreciated .

    Engineering is the effort !

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups