|
Hi,
I've written a small administration tool that does some processing on removable devices. The problem is I need to lock the volume before processing. I have managed to do this but only if noone is using the volume at the time when I am locking. Can I gain exclusive access over a volume and force other processes to not use it for a while?
Mark
|
|
|
|
|
This is not possible.
The FSCTL_LOCK_VOLUME flag requires that there are no open files on the target device before you lock it. If this is a removable device, you can order the disk management system to dismount and remount the device programmatically, which will cause all access to the device to flush and stop. After the remount, you can open and exclusively lock the device.
The best alternative is to enter a while-loop in your program, that will periodically attempt to lock the volume, and when it succeeds, it will then start the processing.
Using a function to exclusively lock a drive and force all others out instantly is considered very bad behaviour from a software. What if the user is copying e.g. images from a camera device when you force the file copier out from the camera's media and lock it ? This, in the worst case, could cause the copier program to end into an access violation error. Using this when a disk defragmenter or similar is in use might even break the hardware or the disk's index system.
You should redesign your application layout so that it can wait for it's turn in order to start the processing work. This is much more favorable than exclusive locking.
If you MUST get exclusive access, then first open the device handle, then dismount it. After that, call GetLogicalDrives which will attempt to remount the device. Enter a successive loop that tries to open the device and lock it. When done, start your processing.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanks... I will try that
This processing will take place at night so no users should be using the PCs in the office at that time. This is just a precautionary measure.
|
|
|
|
|
I'm trying to create a bitmask to say what fields in a database are valid. This would be very much like the LIVF_* items for the LVITEM structure that say what fields in the structure are valid. I'm know pretty much how to setup the bitmask and the flags for it, but I've no idea how I should really use it. Any help is much appreciated. Thanks.
- Aaron
|
|
|
|
|
You just need to use a logical mask, such as 010011. This mask would mean that from an SQL query string, the second, fifth and sixth returned column on each row contain valid values.
There is no actual function which you could use to order a database driver (such as ODBC) to mask certain values. The driver will return all valid values it can extract from the database. It is your job to use e.g. the returned CRecordset-object and mask certain columns from it.
Alternatively, could it be that your application needs redesigning ? After all, if you use an ODBC extension class from here in CodeProject, you can execute an arbitary query into a database and fetch columns by their index or by names. In this case, you wouldn't need a bitmask at all.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Is there any way i can have a modeless form of Messagebox or afxmessagebox?
Thanx.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Unfortunately no, since standard Windows message boxes are modal beasts. But you can craft your own by turning this[^] into a modeless dialog. And when you do, please post the article at CP. Thanks!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Very Smart, you are throwing the question back at me.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
I'm not throwing anything back at you. I just pointed you to a class that you could potentially modify to suit your needs. If get your mod to work, it would likely be useful to the rest of the CP community. Sorry if my suggestion offended you.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
Sorry if my suggestion offended you.
Nah! i was just kidding. I just wanted to know wheather its possible using any standard method. I know i have to write my own in the worst case.
Ravi Bhavnani wrote:
If get your mod to work, it would likely be useful to the rest of the CP community
Yeah i will try to do that.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
If it is a message box to notify the user of some error then consider a balloon tip instead. MessageBox's are a pain in most circumstances as they force the user to stop in their tracks, grab the mouse and click a button. ie. They are very intrusive, which a good UI shouldn't be.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
i m trying to debug a dll and when i try to attach it to a running process, i don't see any process in the process dialog box WHY?
steps:
1: create new dll project
2: do anything.....
3: from the debug menu select start debug option
4: then select attach to process
5: now the process dialog box appears
now i have to select a process from the list but on my system i don't see any process in this process dialog.
Dev
Dev
|
|
|
|
|
deyadav wrote:
i don't see any process in this process dialog
i have no idea why is that happening but as far as i can remember if you are trying to debug a dll then the process attached should load ur dll explicitly or implicitly only then the DllMain gets called, so make a super simple app which calls LoadLibrary("urdll"); and then in dll project put the exe path
Hope it helps
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
i made a sample application and before i try to debug the dll i run the sample application so that i can select it from the process dialog, but there i don't see anything.....
|
|
|
|
|
after making the dll press f5 to debug it a messagbox will come asking for the location of the exe to load enter the path of the executable in that
hope that helps
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
thankx for ur reply but my problem is I DON'T SEE the processes in the process dialog....
Build|Start debug|Attach to process...
now in the process dialog all the running processes r there.... but on my system it's blank(not a single process is there)..... YYYYYYY is my question.... do i have to make any settings for this??????
|
|
|
|
|
This command allows you to attach the debugger into an existing process. It does not allow you to attach your DLL into an existing process.
What you need to do is create a simple application that loads your DLL. Then set a breakpoint into the DLL's DllMain function. Now, run the sample application in debug mode, and after the LoadLibrary call, the DllMain's breakpoint gets fired.
At least on my computer I was able to attach the debugger into a remote process, break it, run through a set of assembly code lines, and then terminate it.
Might it be that you don't have any processes running, or that your user has no rights to see them ? Check CTRL+ALT+DEL and Task Manager. Can you see the processes there ?
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
no i have the admistrative rights and when i do CTRL+ALT+DEL i can see all the running processes in the Task Manager.
|
|
|
|
|
If all you want is to debug a DLL, then you're going about it the wrong way. Attaching to a process is used when you want to debug that process. To debug your DLL, you need a program that loads and uses the DLL. When you hit F5 the first time, VC asks you what EXE to run, that's where you tell it the name of the program that will use the DLL.
For example, if your DLL were an IE plugin, you would use IE as the program.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
You cannot truly appreciate Dilbert unless you've read it in the original Klingon.
|
|
|
|
|
Hi~Can anyone help me? How to input a number and output with the commas for every 3 digits before the decimal point? Is there any function in VC++ library can be used?
|
|
|
|
|
There is no standard way of doing what you are asking for, but there are no of controls that do simiar thing.
Check out these controls here in Codeproject.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
If you're writing a Windows app, you can do this:
CString strFloat;
float fNumber = 123456.10;
strFloat.Format (_T("%f"), fNumber);
TCHAR szFormatted [255];
::GetNumberFormat (LOCALE_USER_DEFAULT, 0, strFloat, 0, szFormatted, 255);
szFormatted should now contain "123,456.10".
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I use VC6 to create toolbar resources. When the toolbars are displayed with the flat XP style, the separators are displayed merely as a couple of extra pixels of separation between the adjacent buttons. I'd like the separators to be displayed as thin lines, as I see in other apps such as Word. How can I make that happen?
I'm using an XP style manifest XML file to instruct the app to use the XP style. That makes the buttons flat, which is what I want. But the logical grouping of buttons is not clear to the user when the only indication is an extra pixel or two of separation instead of a thin line.
Thanking in advance for help.
Cheers
-- Mark Walsen
markwa@notation.com
Notation Software, Inc.
www.notation.com
|
|
|
|
|
I figured out what the problem was. I needed to call CreateEx instead of
Create for the toolbar window (a CToolBar in MFC), and include a
TBSTYLE_FLAT style flat.
Cheers
-- Mark
|
|
|
|
|
Hi all.
I really need how to do this fast:
How do we draw lines that we can pick and move?
I need to store their start and their endpoint.
Can somebody help me please?
aartee.
|
|
|
|