开发者

Not able to see mounted drive using WNetAddConnection2

I am not able to see mounted 开发者_C百科drive using WNetAddConnection2W in Windows Service written in VC++

When i debug the service it returns success but when i open explorer to see that mounted drive it is not there. I am doing this in Windows service where my service is running in administartor previliages. My code looks like :

    lpNetResource->lpRemoteName = L"\\\\172.24.18.240\\praveena\\CIFS";
    lpNetResource->lpLocalName = L"Z:"; 
dwRetVal = WNetAddConnection2W(lpNetResource, wcpPassword, wcpUserName, CONNECT_UPDATE_RECENT); 

When i use the same code in MFC Application it works fine.

Any help is appreciated.


When the drive is added or removed in another session (as it happens in case of Windows services), Explorer doesn't have a way to know about this.

To solve this problem in our Callback File System library, which creates virtual drives (and users do this from services), we have implemented a special shell extension DLL. This DLL listens to signals sent by the user-mode code which performs disk creation (and which is executed in service context). When the DLL receives the signal, it broadcasts WM_DEVICECHANGE system message. Then Explorer catches this message and rescans device list.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜