WNetGetConnection API behaves wrongly when UAC is enabled
-
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");
} -
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");
} -
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:****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