15,895,142 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by lokesh.mavale (Top 6 by date)
lokesh.mavale
17-Mar-14 4:08am
View
sir , it is statement in msdn that.. we can use lockfile() to lock bytes which are outside of file range...!!
how can i use dat?
lokesh.mavale
16-Mar-14 2:25am
View
sir, in msdn it is written that it unmounts the drive and only handle will have exlusive access!!
so how can i write in a file which is on unmounted drive?
lokesh.mavale
8-Mar-14 0:16am
View
CreateFile() returns INVALID_HANDLE_VALUE in handle_of_file!!
lokesh.mavale
5-Mar-14 0:20am
View
with referrance to your answer i have tried this :-->
HANDLE hdest,hf;
DWORD b,write;
hdest = CreateFile("\\\\?\\E:",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
NULL,
NULL);
if (hdest == INVALID_HANDLE_VALUE)
{
MessageBox(NULL,TEXT("NOT OK"),TEXT("NOT OK"),0);
}
if (DeviceIoControl( hdest,FSCTL_LOCK_VOLUME,NULL,0,NULL,0,&b,NULL))
{
MessageBox(NULL,TEXT("OK"),TEXT("OK"),0);
hf = CreateFile(TEXT("E:\\M_lucky.txt"), GENERIC_WRITE, 0, NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (hf == INVALID_HANDLE_VALUE)
{
MessageBox(NULL,TEXT("NOT OK AFTER LOCK I"),TEXT("NOT OK AFTRE LOCK"),0);
}
WriteFile(hf, TEXT("M very lucky"), 13, &write, NULL);
}
CloseHandle((HANDLE)hdest);
CloseHandle((HANDLE)hf);
DeviceIoControl( hdest,FSCTL_UNLOCK_VOLUME,NULL,0,NULL,0,&b,NULL);
hf = CreateFile(TEXT("E:\\MNOT_lucky.txt"), GENERIC_WRITE, 0, NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if (hf == INVALID_HANDLE_VALUE)
{
MessageBox(NULL,TEXT("NOT OK AFTER LOCK"),TEXT("NOT OK AFTRE LOCK"),0);
}
WriteFile(hf, TEXT("M lucky"), 8, &write, NULL);
CloseHandle((HANDLE)hf);
""but........""
after getting exclusive lock on E drive, i am unable to create file.
(i have read that : only hdest(HANDLE) gets exclusive lock on that drive. )
here..!!! i want to create M_LUCKY.txt file..!!
(I need EXLUSIVE access on drive with context to PROCESS)
plz help! thanks a lottt!!
is there any other method for doing this??
lokesh.mavale
2-Mar-14 12:07pm
View
thank you sir!! i have read this .. hope that it will work.!
lokesh.mavale
2-Mar-14 11:57am
View
for a single process of my application!!!
and only my process shuld be able to access locked resource
Show More