|
Hi,
Thanks for the response.
I have looked into the GetSystemTimeAdjustmemt function and when I call this function on my target system it returns 15.625 ms for interval and increment and TRUE for the disabled flag. According to help if time adjustment is disabled then the interval is added to the time at each clock interrupt and time may be synchronize using "other mechanisms".
I do see a task running in the task manager that syncs the clock to RTC causing the jump in the time. I am not sure if it is timeserv.exe or not. It came and went so fast.
Is there a way to change the sync interval to something else other than an hour?
|
|
|
|
|
|
I am writing a program that runs in the background and controls a text editor. My program sends key sequences to the editor to open the Find and Replace dialog box of the editor (this is a dialog box customized by the editor).
So far, this method works great. The only problem I am having is that the dialog box quickly appears and disappear (since I sent the key sequences + enter key as well).
So, now I need to find a way to make the Find and Replace dialog box invisible to the user (when I sent my keys), yet, it must still be able to accept my key sequences.
I was thinking of the following options:
- Each time I want to trigger the Find and Replace dialog, I will set the size to 0 and restore the size later after I have executed my command => Will this work if this is a fixed size dialog box ?
- Set the transparency level to X so that the dialog box is not visible anymore => Is there such an X to do so ? It looks like the dialog caption is always blue
- Or other methods ?
Would really appreciate your help on this.
|
|
|
|
|
You could try those methods.
You could also try and move it out of the screen coordinates.
If even that doesn't work, you might need to write a shell hook which can notify you when the dialog is created and before it becomes visible.
|
|
|
|
|
Hello,
I have a "how-to" question to you in the COM area: I have a non-MFC application and must now expose some of the objects via dual COM interfaces.
In MFC based applications there are ways to make my life easier, I could use MFC classes (e.g. CCmdTarget) and nice macros (mfcdual.h, etc.).
My question: what can I do in my non-MFC Windows app? Is there something similar available (in MFC or ATL) to ease my job? Or do I have to write the COM interface by hand?
Kind Regards
modified on Wednesday, November 11, 2009 5:53 PM
|
|
|
|
|
Umm - ATL has plenty of classes to help you with that. Have a look at the documentation[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
OK, I'll take a look at the documentation.
Thanks
|
|
|
|
|
Right click on the project in solutions explorer.
Select Add -> Class.
Select ATL -> Simple Object.
Following the wizard that pops up you will be able to add dual interface COM objects.
|
|
|
|
|
I developed a customized PageSetupDlg that has some additional controls including a "Restore Defaults" button. When this button is clicked the current settings for margins, orientation and paper size should be reset to certain default values without closing the dialog box. This is not a problem with margins and orientation but I haven't found a way to handle the dropdown list for paper size, i.e. to find the appropriate list entry that my app must select for the desired paper size. Parsing the text of the entries doesn't seem to be a very safe way.
I think there are at least three possible methods to achieve this but I couldn't get any of them to work:
- simply tell the dialog or list box to "select paper size x by y"
- a safe way to enumerate the paper sizes corresponding with each of the list entries (in the correct order!)
- "refresh" the dialog box with a predefined DEVMODE struct
Grateful for any clues,
hx2000
|
|
|
|
|
|
Does this have anything to do with C++?
|
|
|
|
|
Can anyone teach me how to get the process name from a process ID in C/C++ ?
I have a piece of code in C# which I am porting to C++. In C#, there is Process has .ProcessName so it was easy.
Tried to Google but couldn't find the answer.
Thanks a lot.
|
|
|
|
|
|
Oh, so process name is just the EXE filename ? I thought it was something more "important" then that. Thanks a lot for your help.
|
|
|
|
|
hongheo76 wrote: I thought it was something more "important" then that.
You could have looked at the MSDN documentation for the .NET Process.ProcessName Property[^] where it clearly states:
The ProcessName property holds an executable file name, such as Outlook, that does not include the .exe extension or the path.
Best Wishes,
-David Delaune
|
|
|
|
|
Here is a Class to use:
<br />
#if !defined(AFX_PROCESSNAMETOID_H__4217BFFA_FB96_4DAF_A665_3EF82774CD57__INCLUDED_)<br />
#define AFX_PROCESSNAMETOID_H__4217BFFA_FB96_4DAF_A665_3EF82774CD57__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
class CProcessNametoID <br />
{<br />
public:<br />
CProcessNametoID();<br />
DWORD GetProcessID(char* m_name);<br />
virtual ~CProcessNametoID();<br />
private:<br />
HANDLE m_snapshot;<br />
<br />
};<br />
<br />
#endif // !defined(AFX_PROCESSNAMETOID_H__4217BFFA_FB96_4DAF_A665_3EF82774CD57__INCLUDED_)<br />
<br />
#include "stdafx.h"<br />
#include "ProcessID.h"<br />
#include "ProcessNametoID.h"<br />
#include <Tlhelp32.h><br />
<br />
#ifdef _DEBUG<br />
#undef THIS_FILE<br />
static char THIS_FILE[]=__FILE__;<br />
#define new DEBUG_NEW<br />
#endif<br />
<br />
<br />
CProcessNametoID::CProcessNametoID()<br />
{<br />
this->m_snapshot=NULL;<br />
}<br />
<br />
CProcessNametoID::~CProcessNametoID()<br />
{<br />
<br />
}<br />
<br />
DWORD CProcessNametoID::GetProcessID (char* m_name)<br />
{<br />
DWORD m_pid=0;<br />
bool m_status=false;<br />
PROCESSENTRY32 m_ppe;<br />
::memset(&m_ppe,0,sizeof(PROCESSENTRY32));<br />
m_ppe.dwSize=sizeof(PROCESSENTRY32);<br />
__try<br />
{<br />
this->m_snapshot=::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);<br />
if(this->m_snapshot==NULL)<br />
{<br />
__leave;<br />
}<br />
<br />
m_status=::Process32First(this->m_snapshot ,&m_ppe); <br />
int a=::GetLastError();<br />
while(m_status)<br />
{<br />
char *current;<br />
current=m_ppe.szExeFile;<br />
if(lstrcmpi(m_name,current))<br />
{<br />
m_status=::Process32Next(this->m_snapshot ,&m_ppe);<br />
}<br />
else<br />
{<br />
m_pid=m_ppe.th32ProcessID;<br />
m_status=false;<br />
}<br />
}<br />
}<br />
__finally<br />
{<br />
::CloseHandle (this->m_snapshot);<br />
return m_pid;<br />
}<br />
}<br />
Best Reguards !
|
|
|
|
|
Curious why you'd bother to make a class for this. You could have created the same GetProcessID() function without the class wrapper.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
I have a string represent the time and want to convert into time format...
ex) 135621372
I use strptime but it doesn't work ..
I don't want to use the substring method to get hour, minute, and second separtely. It is because I need to do some calculation for the time
struct tm tm;
if (strptime("135621372", "%H%M%S", &tm) != NULL)
{
// do something....
}
Anyone has an idea on how to do the conversion?
Thank you.
modified on Wednesday, November 11, 2009 3:17 PM
|
|
|
|
|
sugarandcream wrote: I have a string represent the time...
ex) 135621372
Based on what? Seconds/milliseconds since some epoch?
sugarandcream wrote: struct tm tm;
Just to be safe, I'd name your variable something other than tm .
sugarandcream wrote: I use strptime but it doesn't work ..
You failed to indicate what "doesn't work" means. If it's because the function does not exist, see here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
the string just represent a time in hour, minute, second, millisecond
135621372 --> hour is 13, minute is 56, second is 21, millisecond is 372
it doesn't work because "tm" in the if statment returns NULL
|
|
|
|
|
sugarandcream wrote: it doesn't work because "tm" in the if statment returns NULL
Can you step into strptime() to find out why?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I trying using the another string separate by ":"
ex) 13:56:21:372
for the if statement, i use
if (strptime("13:56:21:372", "%H:%M:%S:%f", &tm) != NULL)
this time, it does not return NULL
However, the string that I need to parse does not have any delimiter.
Is there any way to convert a string to time format??
thanks..
|
|
|
|
|
Have you considered something like:
char *szTime = "135621372";
strncpy(szHour, szTime, 2);
strncpy(szMinute, &szTime[2], 2);
strncpy(szSecond, &szTime[4], 2);
strcpy(szMsec, &szTime[6]);
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
is that the only way i can do?
since i need to do calculation of the time, such as add and subtract...
for example
time is 001100123 (better way to see is 00:11:00:123)
if I need to subtract an hour from it, the new time is 23:11:00:123
|
|
|
|