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. WNetGetConnection API behaves wrongly when UAC is enabled

WNetGetConnection API behaves wrongly when UAC is enabled

Scheduled Pinned Locked Moved C / C++ / MFC
helpsysadminjsonquestion
3 Posts 2 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
    atm menon
    wrote on last edited by
    #1

    Hi, I am using WNetGetConnection() API to check that my network drive(mapped to a local share folder) is connected or not. When i run this application as run as administrator with UAC enabled, this API return success even if n/w drive is disconnected. Its works fine when i run application without admin privilege( standard user). Anybody got the same issue? Any help or guidance would be appreciated. Sample code

    LPTSTR lpszDeviceName = 0;
    lpszDeviceName = new TCHAR[ 256];
    DWORD dwcchBuff = MAX_PATH;
    DWORD dwResult = 0;
    dwResult = WNetGetConnection( _T("Z:"), lpszDeviceName, &dwcchBuff );
    if( NO_ERROR != dwResult )
    {
    printf("Media removed\n");
    }
    else
    {
    printf("Media inserted\n");
    }

    M 1 Reply Last reply
    0
    • A atm menon

      Hi, I am using WNetGetConnection() API to check that my network drive(mapped to a local share folder) is connected or not. When i run this application as run as administrator with UAC enabled, this API return success even if n/w drive is disconnected. Its works fine when i run application without admin privilege( standard user). Anybody got the same issue? Any help or guidance would be appreciated. Sample code

      LPTSTR lpszDeviceName = 0;
      lpszDeviceName = new TCHAR[ 256];
      DWORD dwcchBuff = MAX_PATH;
      DWORD dwResult = 0;
      dwResult = WNetGetConnection( _T("Z:"), lpszDeviceName, &dwcchBuff );
      if( NO_ERROR != dwResult )
      {
      printf("Media removed\n");
      }
      else
      {
      printf("Media inserted\n");
      }

      M Offline
      M Offline
      Malli_S
      wrote on last edited by
      #2

      On my machine, the code seems to be working properly in both the scenario. Please ensure that you've not set user specific rights to the locally shared folder.

      [Delegates]      [Virtual Desktop]      [Tray Me !]
      -Malli...! :rose:****

      A 1 Reply Last reply
      0
      • M Malli_S

        On my machine, the code seems to be working properly in both the scenario. Please ensure that you've not set user specific rights to the locally shared folder.

        [Delegates]      [Virtual Desktop]      [Tray Me !]
        -Malli...! :rose:****

        A Offline
        A Offline
        atm menon
        wrote on last edited by
        #3

        Hi, Thanks for your reply. Hmm.. I have just shared the folder( permission to everyone i think). The problem is still exists when UAC is enabled( my UAC settings is default) and I run application as admin. Its works fine when UAC is disabled( i.e Never notify). Thanks Arun

        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