Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Dear All,

I've created an MFC ActiveX control to use in web based application. In that ActiveX control, there is a method to create a folder in a selected drive e.g. (C:\MyFolder\Folder1). This ActiveX(.ocx) is working fine if i try to create the folder from HTML page (which is in local PC ) in both windows XP and windows7.

But the same not working in windows7 when HTML page is loaded from the server. It is giving error code 5 (by using GetLastError()) .

Any help is appreciated, thanks in advance.
Posted
Updated 3-Jan-12 23:22pm
v5

1 solution

On Windows 7 such an operation is not allowed to standard user code. You have to run your application 'as administrator' or programmatically elevate the application level of execution (there are articles here at CodeProject about it, see, for instance: "Riding the Vista UAC elevator, up and down"[^]). Or you may, simply, create the folder in a less 'protected' place.
 
Share this answer
 
Comments
Cpp_Com 4-Jan-12 1:54am    
Thank you Pallini.

But if i use same code as a standalone mfc application its working. But while using this code in an ActiveX control used by web browser to create directory its giving error.

So cannot understand what to do?
Albert Holguin 4-Jan-12 15:51pm    
See the additional notes from jack and myself.
JackDingler 4-Jan-12 15:54pm    
Your browser has different UAC permissions. Your ActiveX control inherits the brower's permissions. CPallini's note will lead you to the answer. You need to programmatically elevate the controls permissions, so that it can create folders.
Albert Holguin 4-Jan-12 15:46pm    
You should have replied to cpp_com instead of posting a comment to cpallini.
Albert Holguin 4-Jan-12 15:48pm    
This sounds like the problem... I would recommend moving the file to a location that Win7 is ok with since these permission schemes aren't going away and you really don't want to make your user be an admin unless he absolutely must be. +5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900