|
How can i close file handles used by another processes ?
|
|
|
|
|
Can you more example what applications?
|
|
|
|
|
nitinmx wrote: How can i close file handles used by another processes ?
I'm not sure why you’d want to but as far as I know they answer is no, or at least not easily. The only way I can think of to achieve this is to get the owning process to close the HANDLE for you via code injection: by using SetWindowsHookEx for example. Again, doing this is dubious to say the least.
Steve
|
|
|
|
|
Hi,
I'm working under VS 6 C++ and need to parse date from YYYY-MM-DD HH:MM:SS to any of SYSTEMTIME or tm structures. I'm struggling to use CTime, because it requires to run under MFC(does it? ) and I'm creating a COM object. Or is there a way to use CTime while creating COM ?
PS : I'm not having problems with parsing "YYYY-MM-DD HH:MM-SS" formated string into Int values and filling them into e.c. SYSTEMTIME structure, but I don't know how to compare two dates created that way. When I try to create FILETIME from SYSTEMTIME (to be able to compere them) using SystemTimeToFileTime(...) method, it doesn't work corretly. I suppose it's beacuse of the source SYSTEMTIME doesn't have all fields set (Day of Week and MILISECONDS - which are for me irrelevant, I can set miliseconds to zero but I don't know how to determine day of week)
thanx for any ideas
|
|
|
|
|
I dont know exactly what your problem is, but maybe this will help
SYSTEMTIME ST;
GetLocalTime(&ST);
CString TimeStamp;
TimeStamp.Format("%ld-%ld-%ld%ld:%ld",ST.wYear,ST.wMonth,ST.wDay,ST.wHour,ST.wMinute);
Note that you might have to make a simple function which adds a 0 infront of some of the variables for it to look nicer
//Johannes
|
|
|
|
|
You can use CRT function mktime() to make a time_t, and then you can do everything you want. Take a look at CTime's source. (c:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\TIMECORE.CPP )
|
|
|
|
|
Zilo(svk) wrote: I'm struggling to use CTime, because it requires to run under MFC(does it? )
You can also use ...
_tcsftime
|
|
|
|
|
|
...or just use strcmp() if you just need to compare times. It will work on the format you supplied, and it's faster than any conversion you can make. If you're about to make alot of comparisons (like sorting) converting it to a number might be the way to go.
|
|
|
|
|
Hi. I love using this forum, you guys are my salvation!!
The question I have know, is that:
When I run the program if I push the Enter button the app is closed. I don´t care if I push the Enter button and it calls the OK button in my app, but it doesn´t happen. Pushing Enter is just like pushing Escape. How can I fix this?
Thanks everybody!!
|
|
|
|
|
Take a look at http://visualcpp.net/index.php?qID=28
//Johannes
|
|
|
|
|
Set the "Default Button" property of the button to False(From the property window). You can set the default property to true which ever button handler you want to execute on pressing enter Key.
Anurag Gandhi.
|
|
|
|
|
Double Click to Add the event handler for OK Button.
Add the Following code in the function:
if(0x8000 & GetKeyState(VK_RETURN))
return;
OnOK();
Now, Your Dialog Box will not Quit even if Ok Button is set to focus.
Anurag Gandhi.
|
|
|
|
|
Thanks for answering anurag. There is another problem.
The button I set as Default Button is a CImageButton, so it has the Owner Drawn property set to TRUE. When I click the Default button property it loses the Owner Drawn property and with it, his image. Moreover, it is useful for me on secondary Dialogs, but in the main dialog I have no default button, and don´t want nothing to be as default, I need nothing to happen when I push the Enter button. is there any other solution?
Thanks again
|
|
|
|
|
It still does not work. When I press Enter it does not get into the procedure asigned to the OK button.
I wanna cry...
|
|
|
|
|
If you want nothing to happen when you press Enter Key (It's Enter Key, not Button).
Use the following code at the begining of all the Button event handler functions:
if(0x8000 & GetKeyState(VK_RETURN))
return;
This code will return from the function whenever you will press enter key.
I think this will help you.
Anurag Gandhi.
|
|
|
|
|
hi!
try pretranslatemessage function...
BOOL CDlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->wParam == VK_RETURN) // if enter key pressed return true
return TRUE;
return CDialog::PreTranslateMessage(pMsg);
}
hope it helps...
newbie
|
|
|
|
|
This is a good idea Newbie,
But it will block Enter Key through out the dialog box. Not only for Some Buttons.
Anurag Gandhi.
|
|
|
|
|
THANK YOU!!!
THIS IS THE BEST FORUM I´VE EVER VISITED. That worked!
Thank you ginjikun.
|
|
|
|
|
It is not recommended to override PreTranslateMessage() for this purpose.
The reply in This thread is fine.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
In this case, Check if your Ok Button is your Default Button.
If not Make it, Then only it will work.
Anurag Gandhi.
|
|
|
|
|
Hello everyone
I am making an application in VC++ 6.0 and MySQL my requirment is that I Want to save MS Word file in database how can i do it.
How i will be upload these file to database .
Actually I want save file in a folder (at local server) and want to save file name in database .
Please any one help me ...
If possible give some link of such type of application.
Regard's
Kaushik
|
|
|
|
|
Y_Kaushik wrote: I Want to save MS Word file in database how can i do it.
This should get you started. Loading image files from a database, using ADO[^]
Y_Kaushik wrote: Actually I want save file in a folder (at local server) and want to save file name in database .
That's a better way of handling it I think. If the folder on the server is shared copy the image there and save the image name / location in the db.
|
|
|
|
|
hi!
i would like to ask what is the best way to store and sort (e.g. priority queue,multimap,sorted vector, etc) my date which consist of 2 criterias.
first is the priority, then according to group.
sample is...
priority 1, group1
data 1
data 2
priority 1, group 2
data 1
data 2
data 3
priority 2, group 4
data 1
group 5
data 1
...
each group may consist of 1 or more data
i was thinking of priority_queue however some of the data are stored til the end of the application. i am not sure if queue have somekind of peek method.
and vector using sort method, but the data are added throughout the lifetime of the application indefinitely and not just 1 time... sort may be too expensive to be called many times.
thanks for any help!
newbie
|
|
|
|
|
Explain in deatail.... What is your actual requirment
I thnink your question is incomplete
Regard's
Kaushik
|
|
|
|