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. COM
  4. Working with the Shell and an object in a virtual folder

Working with the Shell and an object in a virtual folder

Scheduled Pinned Locked Moved COM
helpdatabasesysadminlinuxannouncement
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.
  • D Offline
    D Offline
    DeepT
    wrote on last edited by
    #1

    I am trying to enable and disable a network adapter (not release and renew). It seems the only way to do this is through the shell object. I have been grinding on this problem for over a week. Currently I am stuck trying to apply a 'verb' to an contextmenu object. Here are two relevent code snippets: // Now loop through the menu and see if we see the enalbed menu item. bool FoundOne = false; bool ContextMenuLoop = true; CString MenuItemName; CMenu MyMenu; MyMenu.CreatePopupMenu(); MENUITEMINFO MenuItemInfo; ZeroMemory(&MenuItemInfo, sizeof(MenuItemInfo)); MenuItemInfo.cbSize = sizeof(MenuItemInfo); MenuItemInfo.fMask = MIIM_ID | MIIM_TYPE; char Buff[50]; ZeroMemory(Buff, sizeof(Buff)); MenuItemInfo.cch =49; MenuItemInfo.dwTypeData = Buff; MenuItemInfo.fType = MFT_STRING; int Offset = (int)ContextMenu->QueryContextMenu(MyMenu, 0, 1, 30000, CMF_EXPLORE); unsigned int J; // Loop through all menu items and see if it has a Disable option for (J = 0; J < MyMenu.GetMenuItemCount(); J++) { int T; T = MyMenu.GetMenuItemID(J); if (T > 0) { MyMenu.GetMenuString(T, MenuItemName, MF_BYCOMMAND); MyMenu.GetMenuItemInfo(T, &MenuItemInfo); if (DISABLE_VERB == MenuItemName) { FoundOne = true; break; } } } At this point I have the context menu object, and actually found the DISABLE_VERB. I also MenuItemInfo for this particular menu item. So far so good... // Now that we found one, we need to cycle it if (true == FoundOne) { HRESULT Hr = NULL; CMINVOKECOMMANDINFO Cmd; ZeroMemory(&Cmd, sizeof(Cmd)); Cmd.cbSize = sizeof(CMINVOKECOMMANDINFO); **Cmd.lpVerb = MAKEINTRESOURCE(MenuItemInfo.wID);** Hr = ContextMenu->InvokeCommand(&Cmd); int L = GetLastError(); Sleep(100); Cmd.lpVerb = ENABLE_VERB; // Hr = ContextMenu->InvokeCommand(&Cmd); } The line in bold is the key line. Its where I set my verb. If I use the DISABLE_VERB, which I just found, it gives me an invalid parameter error (80030057). I set the verb directly, such like Cmd.lpVerb = DISABLE_VERB; when I get this error. I have no idea why since I searched for it and found it. Next I tried using the wID (as it is done in this code snippet) and while it accepted the parameter, it did the wrong thing (It tried to bridge network connections). I thought the index might be off by +/- 1, but that didn't help. Can anyone tell me what I

    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