Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am Trying to set Short Name of A file opened by CreateFile Function with GENERIC_ALL access mode and FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE.

To Set Short Name I used Function SetFileShortName but it gives Run time error 1314 (A required privilege is not held by the client.)
How can I set This privalege? Or setTheshort name Alternatively ?

Thanks in Advance,
Ajay
Posted

I am at a loss how you'd set the short name, isn't it a truncated version of the long one ? Having said that, you need to set up your application to run as admin. Here[^] is an artile on how.
 
Share this answer
 
The documentation for SetFileShortName says that the file must be opened with GENERIC_ALL and FILE_FLAG_BACKUP_SEMANTICS flags (GENERIC_ALL | FILE_FLAG_BACKUP_SEMANTICS). Is that how you've opened the file?

Also the SE_RESTORE_NAME privilege must be enabled.
Here is how privileges can be enabled - Enabling and Disabling Privileges in C++[^]
 
Share this answer
 
Comments
Aby321 7-Feb-12 0:16am    
I rtied both ways. And even I Enabled SE_RESTORE_NAME but still the problem
is there. Are there any other ways?


Ajay.
«_Superman_» 7-Feb-12 0:39am    
Have you tried running the application with admin privileges like Christian said?
You can check if it works that way by right clicking on the executable and selecting Run as Administrator.

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