|
Anonymous wrote:
Can I rename/delete a file another process has open?
Simple answer: No
Complex answer: You can't while it's open. You can use MoveFileEx() to delay the rename/delete until the next reboot, and let Windows do it for you at startup.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
You should check if the file is open or not before trying these operations
Sudhir Mangla
http://Programmerworld.net
(Free books , articles and Source Code)
|
|
|
|
|
I was following some online examples on creating a
simple user form in visual c++, and I just came upon a
strange thing...that is, after putting in teh text
boxes and radio buttons etc, we go to put in a button
for the user to click, then according to the online
instructions, by double clicking on that button it
should take me to the code section where I can then
define what I want the form to do...but I just
noticed that in doing so, it takes me to the .h and
not .cpp file to define the code! That is kind of
strange..shouldn't I define my codes in the .cpp
file?
Also, when I try to put in additional logics, such as
declaring CString variables to do stuff with it, it
tells me CString is not declared...this is really
strange...
any assistance would be greatly
appreciated...
thank you!
|
|
|
|
|
You're using MFC, right ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Anonymous wrote:
simple user form in visual c++,
What version of VC++ did you use. I think You can`t do that in VC++ 6. Corect me if i`m wrong.
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
I'm trying to disable the movement of the physical mouse, but still be able to set its position on my own, via SetCursorPos(). The only solution I could come up with is to get the current mouse sensitivity, set it to zero, then revert back to the original sensitivity when done. The promblem is that I have no idea how to do this, and could not find any information on MSDN or by searching online.
Alternatively, if anyone has a better method of achieving the same thing, I would greatly appreciate it.
|
|
|
|
|
Any way to force process to unload library????
I working on update component ( oracle ), it seems i can do LoadLibrary and FreeLibrary when needed just ok, except for dll's been locked by OS. I am aware of debug setting for that tells XP to unload every library it is not been used, but this is way to drastic.
Couple of other options comes to mind, but I don't want to reinvent the wheel and not even sure it would work.
1) From process A create process B, when done exit B hoping cleanup would unload DLL or may be just issue plain kill.
2) allocate memory, load dll (PE), do fixup entry table etc etc etc as long as darn LoadLibrary is not been used.
3) Call freelibrary until XP frees stupid library or I blow away my stack.
4) Other options?
Thanks,
Brian
|
|
|
|
|
Do what everyone else does.
You use MoveFileEx to get the files copied to the correct places during the system restart.
Prior to restarting, add a RunOnce program that will register the DLL while the system is starting up.
Tell user to reboot system.
This is the 'recommended way to repalce DLL that are in use.
Look at all the MS security udpates, constant reboots of machine, eh? Works for them.. should work for you!
|
|
|
|
|
Hello.
I need pass a value stored in an int variable to a CString variable. Someone can help me?
jesus choy
|
|
|
|
|
Try searching through this message board. I think you will find this has been answered many times.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
|
<br />
CString st;<br />
int k=10;<br />
st.Format("%d", k);<br />
Now st become "10".
Is that your needed?
|
|
|
|
|
|
Hi,
I need to do the following:
- A process (outside my control completely) generates a file.
- I need to read the file from some offset (near the end) and once I reach the end, wait at the end for more data
I don't want to keep polling for more data (as I don't want to waste CPU cycles). Is there some API I can use?
Cheers.
|
|
|
|
|
|
Thanks, I definitely will.
|
|
|
|
|
Good. Please register here at CP instead of posting Anonymously. I tend to ignore anonymous posts as do others.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Hi,
I have a CDialog which contains several CEdit fields. I would like to be able to set one of those CEdit fields to have initial input focus.
I'm trying to use the following code but it does nothing. I've made sure editField1 is valid at that point.
<br />
BOOL MyDialog::OnInitDialog() <br />
{<br />
CDialog::OnInitDialog();<br />
editField1.SetFocus();<br />
<br />
return true;<br />
}<br />
Thoughts/hints?
Thanks
Hua-Ying
|
|
|
|
|
Calling SetFocus() in a dialog (or anywhere else) can be problematic. You could try editField1.PostMessage( WM_SETFOCUS ... ) which will have a far better chance of working. You need to test stuff like this on all patforms your app will run on.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
When I tried what you suggested, the CEdit field stops accepting user input(just beeps when you type)? It does put the caret in the edit box when the dialog starts up though.
editField1.PostMessage(WM_SETFOCUS);
Hua-Ying
|
|
|
|
|
hyling wrote:
When I tried what you suggested, the CEdit field to stop accepting input at all? It does put the caret in the edit box when the dialog starts up though.
Have you specified the correct vaues for the PostMessage() wParam and lParam params. Look at WM_SETFOCUS in the Help for details.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Would you explain why you said this: Calling SetFocus() in a dialog (or anywhere else) can be problematic. I couldn't find anything discussions about this with google.
Also, I could never get PostMessage to work right.
I tried this:
<br />
mIDField.PostMessage(WM_SETFOCUS, (WPARAM)m_hWnd, 0);<br />
According to the docs:
Parameters
-wParam
Handle to the window that has lost the keyboard focus. This parameter can be NULL.
-lParam
This parameter is not used.
Thanks
Hua-Ying
|
|
|
|
|
hyling wrote:
Would you explain why you said this: Calling SetFocus() in a dialog (or anywhere else) can be problematic. I couldn't find anything discussions about this with google.
You can and do get into race conditions where your code is trying to SetFocus and Windows is also trying to SetFocus(). A common mistake people make where this is evident is validating a control in its OnKillFocus() handler and calling SetFocus() when it is invalid to set the focus back to the control loosing focus. This won't work because upon return from OnKillFocus() windows will set the focus to the next control etc. PostMessage() is a way to handle this scenario.
David has pointed out the correct answer however.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
When posting code snippets, it's beneficial to post them verbatim rather than typing them in manually. This is evident in the fact that you are returning a bool from a BOOL method.
Since OnInitDialog() is created by AppWizard or ClassWizard, you've no doubt noticed the comment that gets placed near the bottom of the OnInitDialog() method:
return TRUE;
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
AppWizard didn't create a OnInitDialog function for this class, I had to add it in by hand and didn't see the comment before.
You're right, I should have been returning false for this function.
The following code works for me:
<br />
BOOL MyDialog::OnInitDialog() <br />
{<br />
CDialog::OnInitDialog();<br />
editField1.SetFocus();<br />
<br />
return FALSE;<br />
}<br />
Thanks!
Hua-Ying
|
|
|
|