|
Johan - I'm pretty sure for WinNT, Win2k, WinXP you can query a PDH (Performance Data Helper) Value called 'System Up Time', but I dont have any code here to prove it
Garth
|
|
|
|
|
|
Yes there is a gettickcount() function to calculate the uptime
i think it will return the values in seconds. you can calculate it
accordingly.
any further details refer WMI classes in msdn
Pradeep
|
|
|
|
|
Milliseconds actually.
This will be the simplist, most universal approach, though the DWORD counter will rollover every 49.7 days, so you'll have to take that into account.
modified 12-Jul-20 21:01pm.
|
|
|
|
|
QueryPerformanceCounter and QueryPerformanceFrequency will help. They have a roll-over that is much much more than 49 days.
Don't try it, just do it!
|
|
|
|
|
Thank you everyone for your kind responses
You do however not answer my question, I want to detect the date and time of the last startup/reboot, not the time elapsed since then.
Maybe I should have been a bit more informative, I am adding this code as part of a software protection system, and I want to find a way to detect of the system time has been changed to a valid day within their evaluation period.
On the old Win architecture, this works perfectly by checking the files mentioned above. But how can this be achieved on the NT platform?
/Johan
|
|
|
|
|
I need to write a class which manipulates char in Unicode form.
So i need materials related to implementation techniques for unicode using c++ class..
thanx in advance
|
|
|
|
|
How about using std::wstring instead?
Painted on the side of a dog trainer's van: SIT HAPPENS
|
|
|
|
|
No NO my question is
i need to write a class which deals with unicode...
If i store a particular char in the class, using some functions i should be
able to say its catagoreis.............
there are nearly 30-40 catagories....
so i need to catagory the char which is stored in my class...?
any guess?
|
|
|
|
|
hi,
i'm doing a project where i hav a transmitter in a place n a receiver connected to the soundcard of the system.now my reciver is one which always does hav noise n whenever i click on a button in the transmitter i can transmit the signal.now the problem is my pgm has to detect when the transmitter is switched on n when it is off so tht it can record the voice.i'm struck.plzz help.imp as i'll hav to submit it sonn.
thnx.
aania
|
|
|
|
|
Hello...
I am trying to make a WYSIWYG editor and for that I am using the MSHTML control (in a win32 application).
Well it works fine you can set properties of the text with the build in functions...
Than I get a text range (with IHTMLTxtRange) (i can get the text range with no problem) and modify it using pasteHTML (i am doing that to apply font properties...) (i can do what I want but maybe there is some problem here).
Well after that I cannot change anything with the built in functions... But my functions continue working...
I am thinking about the selection range... Do I have to select the whole document and out it in a range in order to edit it with the built in functions?
What may be the problem?
Thank you very much in advance for your answers...
Well... I am a beginner ...
|
|
|
|
|
Problem solved...
Well... I am a beginner ...
|
|
|
|
|
My question is related to client/server programming;
Can we communicate between client and server which have benn developed using different technologies, e.g. client using a Winsock control and server using CSocket class, or say raw winsock apis, MFC etc.
What about different plateforms
|
|
|
|
|
Normal winsock and raw winsock can work together...
CSocket should work also...
Well... I am a beginner ...
|
|
|
|
|
Hello
I have few questions related to MFC.
1. I have added a tree control and a rich edit control in Dialog based application. My aim is that when i click an item in tree control, text is displayed in rich edit control. I have modified the code of NM_CLICK event handler for a tree control. So that when i click an item in tree control, an operation is perfomed. But i have to click that item two or three times to display text in rich edit control where as text should be displayed in rich edit control by clicking item just one time. Can anyone please tell me where i am doing mistake? I have given my code below
void CTreeDlg::OnClickTree(NMHDR* pNMHDR, LRESULT* pResult)
{
CTreeCtrl* pCtrl = (CTreeCtrl*) GetDlgItem(IDC_TREE);
HTREEITEM hCurSel = pCtrl->GetSelectedItem();
if (pCtrl->GetItemText(hCurSel) == "Aqueel") // if i clicked on Aqueel in tree control
{
// displaying contents of a file in rich edit
CFile cFile(TEXT("myfile.rtf"), CFile::modeRead);
EDITSTREAM strm;
strm.dwCookie = (DWORD) &cFile;
strm.pfnCallback = WriteEditData;
m_Info.StreamIn(SF_RTF, strm);
}
*pResult = 0;
}
2. How can i clear the contents of a rich edit control.
3. After i have included a .rtf file as a resourse in my project, how can i display it in rich edit control.
Please help me
Thank you.
Aqueel A. Mirza
We Believe in Excellence
|
|
|
|
|
1) Don't handle NM_CLICK. This only works if you select a tree item
with the mouse. If you use the cursor keys to navigate around the tree,
NM_CLICK does not happen. Use
ON_NOTIFY_REFLECT( TVN_SELCHANGING, OnSelectionChanging)
ON_NOTIFY_REFLECT( TVN_SELCHANGED, OnSelectionChanged)
//this routine is called if tree item is selected.
//Set *pResult to 1 to PREVENT this item from being selected
//Set *pResult to 0 to ALLOW this item from being selected
void CMyTreeView::OnSelectionChanging(NMHDR* pNMHDR, LRESULT* pResult){
NM_TREEVIEW* pTreeView = (NM_TREEVIEW*)pNMHDR;
if(OkayToSelectThisTreeItem(pTreeView)){ //insert your own check
*pResult=0; //item will be selected
}
else{
*pResult=1; //item will not be selected
}
}
//This function is called after a tree item is successfully selected.
//It is also called numerous times when tree branch is
//expanded, collapsed, added or deleted,
//which is why deleting a branch is usually so slow.
//Note: unlike OnSelectionChanging, *pResult is NOT used here
void CMyTreeView::OnSelectionChanged(NMHDR* pNMHDR, LRESULT* pResult){
NM_TREEVIEW* pTV = (NM_TREEVIEW*)pNMHDR;
//figure out which RTF to load
//load the RTF into the window
}
To load the RTF from a file, this is easy.
You can make the RTF a new type of resource.
See http://www.codeproject.com/winhelp/myhelpdialog.asp
|
|
|
|
|
Thanks. It works perfectly
|
|
|
|
|
hi,guys,
How to set the initial position of Dialog?
Thanks.
Best Regards,
KHLin
|
|
|
|
|
Hi khlins,
In dialog proc use MoveWindow(...) on "WM_INITDIALOG" message.
This would position the dialog box where you wanted.
Have fun !
Cheers,
Vishal
|
|
|
|
|
Hi, Vishal
I got it.
Thank you very much.
Best Regards,
KHLin
|
|
|
|
|
khlins wrote:
How to set the initial position of Dialog?
In Continuation With Mr. Vishal ,
SetWindowPos(...) api will also help in this case
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Compiling...
MP3PLAYER.cpp
c:\documents and settings\administrator\desktop\sebin\mp3player\mp3playerdlg.h(14) : error C2084: function 'long __stdcall DllGetClassObject(const struct _GUID &,const struct _GUID &,void ** )' already has a body
MP3PLAYERDlg.cpp
c:\documents and settings\administrator\desktop\sebin\mp3player\mp3playerdlg.h(14) : error C2084: function 'long __stdcall DllGetClassObject(const struct _GUID &,const struct _GUID &,void ** )' already has a body
Generating Code...
Error executing cl.exe.
MP3PLAYER.exe - 2 error(s), 0 warning(s)
these are the errors i got when i compiled my project..i am doing a project to create an mp3 player which reads data bit by bit...
for playing i followed the code in the memfile in directx8..then i got some linker errors...
then i write this code at the start of my mfc project...
// DllGetClassObject
extern "C"
STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
AFX_MANAGE_STATE (AfxGetStaticModuleState());
return AfxDllGetClassObject (rclsid, riid, ppv);
}
when compiled i got the above said errors...
please help me...i am a beginer in mfc...and vc....
sebin
|
|
|
|
|
please someone answer me...
sebin
|
|
|
|
|
The compiler is saying that it found the definition of DllGetClassObject in both MP3PLAYER.CPP and MP3PLAYERDlg.cpp. You have included mp3playerdlg.h file in both those files and provided the implementation of DllGetClassObject in mp3playerdlg.h.
You need to have just the declaration in the header file and move the implementation to a cpp file.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hello All,
I'm using the Speech SDK inside a COM module thus:
HRESULT hr;<br />
ISpVoice * pVoice = NULL;<br />
......<br />
hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);<br />
if(! SUCCEEDED(hr)) MessageBox (NULL, "Cant load Voice",NULL,NULL);<br />
else hr = pVoice->Speak(L"Hello World", SPF_DEFAULT, NULL);<br />
......<br />
pVoice->Release();<br />
pVoice = NULL;
It compiles and - amazingly enough - works ok.
Now, if I change the 2nd parameter in Speak() to SPF_ASYNC or SPF_ASYNC | SPF_PURGEBEFORESPEAK, to call it asynchronously, thre is no sound at all.
Thanks
alex
'Architecture is music frozen in space.'
|
|
|
|