|
Hi guys,
in my software I need to measure time duration between two hardware signals (which come via RS232 connection). And I'd need that with accuracy to millisecond. I'm wondering what's a reasonably good way (meaning good accurate results) to go about it? I'm now only thinking of using SetTimer() and KillTimer() with a counter variable to count the time, would that be able to provide a good accuracy?
Thanks
|
|
|
|
|
QueryPerformanceCounter does a good job.
Take a look at this article.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
One way would be to use either the _ftime() or _ftime64() function.
e.g.
__int64 getCurrentMilliTime()
{
__timeb64 time;
_ftime64(&time);
__int64 seconds = (__int64)time.time;
return (seconds * 1000) + time.millitm;
}
_ftime()/_ftime64()
|
|
|
|
|
On NT/W2K/XP, you can use GetTickCount()
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I'll have to remember that one. That's a bit more friendly than the method I gave. (Though not as useful if you actually want the time. )
|
|
|
|
|
thanks alot guys, very helpful
|
|
|
|
|
Can anybody show me how to write "\\" to a regitry.
I tried this:
reg.SetStringValue(HKEY_LOCAL_MACHINE,"SOFTWARE\\MyReg\\","NetDirection",std::string("\\MyServer\\Direc\\path").c_str());
but it only writes \MyServer\Direc\path
I want
\\MyServer\Direc\path
Using C++, console application
any help is greatly appreciated
|
|
|
|
|
The answer is more simpler than you can imagine.
The backslash character '\', when occuring in a string, represents a command for the compiler (tabulator = '\t'). To print a backslash character, you need to use a double-backslash in the string '\\'. To print a double-backslash, you need to use a triple backslash in there '\\\'.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Antti Keskinen wrote:
To print a double-backslash, you need to use a triple backslash in there '\\\'.
Actually you need four. Each pair of backslashes is interpreted as the literal character '\' by the preprocessor.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Use ("\\\\MyServer\\Direc\\path") .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
A friend has an interesting problem. He has a site that allows people to register, and once they register they can download an application that will consume data from the site. What he needs is a way for the site to somehow stamp a user's ID onto the application so that when it's downloaded and first run it will immediately know to access the website using that person's info.
I can think of a number of dodgy (and potentially not cross-browser friendly) solutions such as using cookies, dynamically building an install file on the fly in order to include a resource file with the user ID, or even simply asking the user when they first run the app to enter their details, but there must be a simple, neat way that my caffeine starved brain is missing.
cheers,
Chris Maunder
|
|
|
|
|
Here's an (admittedly simple-minded) approach:- The process of registration causes the site to create a user-specific copy of the download app. If the app is
foo.exe , the registration process creates the file foo_1234.exe (where 1234 is the user specific id), if it doesn't already exist.
- The app sends the user's id (gleaned from its filename) in its HTTP request to download data, causing the host to respond with user-specific content.
[edit]
Of course, you should use something more cryptic than just the user's id. Maybe add a timestamp and a checksum at the end.
[/edit]
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I thought of that one too but because the user's ID is part of the filename it's open to abuse/spoofing, unless you seed and encrypt the id.
cheers,
Chris Maunder
|
|
|
|
|
Chris Maunder wrote:
unless you seed and encrypt the id.
Easily done using MD5 methinks?
Another option would be to download a customer specific encrypted binary datafile (a la the old "license key file"s of yore) that would be accessed by the (generic) app when making the request. There are ways to prevent the license file from being used by the downloader app on another machine.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
The other 'old way' would be to patch a copy of the .exe.
0. Write application with a global variable that is initialized with some distinct data.
1. Server gets new registration and creates an encrypted blob of the user information.
2. Server creates a copy of the .exe to be downloaded and writes the encrypted blob over the place where the distinct data is.
3. Now when the app is run by the user the data in the global variable is passed, decrypted, and the user information used for the connection.
This really does 'stamp a user's ID onto the application' which means all copies the user makes (and may give to friends) will use this information ... although if you use the ethernet MAC as part of the user information you could prevent this.
This method would have whatever drawbacks you felt 'dynamically building an install file on the fly in order to include a resource file with the user ID' has.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
If he wants to go the "whole hog", he could use our Call Home Licensing technology: http://www.tectite.com/tectitelic.php
Russell Robinson (russpub at rootsoftware dot com)
Author of TTMaker (Advanced Timetabling Software)
http://www.rootsoftware.com
|
|
|
|
|
I have a serrious problem.I've developed an application on VC6 that used to work fine. Now I have converted it on VC.NET 7.0 and builded in RELEASE configuration. The problem is that it only works on my computer. On other computers that don't have VC installed it just doesn't start. If started with depends.exe (XP Support Tools) it gives the following error:
Second chance exception 0xC00000005 (Access violation) occured in "NTDLL.DLL" at address 0x77F8243D
Exited "program" with code 128(0x80)
They have all the necesary dlls. What should I do? I'm disperate.
Could it be because they don't have the .NET framework installed?
nemo
|
|
|
|
|
People I need help in drawing a math graph like a*x^2+b*x+c
in Visual C++.Anybody can help me with free code or anything else??
|
|
|
|
|
|
How do you programmatically show desktop, just like that ".scf" file(%APP_DATA%\\Microsoft\\Internet Explorer\\Show Desktop.scf) does?
|
|
|
|
|
keybd_event(VK_LWIN, 0, 0, 0);
keybd_event(VK_D, 0, 0, 0);
keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
If it's to run on XP, you can Automate the shell via IShellDispatch4::ToggleDesktop - see here:
http://blogs.msdn.com/robgruen/archive/2004/02/24/79294.aspx
If it's not, then I think you are stuck with simulating a WIN+M key press.
|
|
|
|
|
Hi,i would like to know that how to create a skinned gui controls in directx just like those games do. I need it for my new game,so please,someone please tell me how to do it...thanks!
|
|
|
|
|
There are no skinned UI controls in DirectX. Everything is completely drawn and operated by you.
First, design the controls using, for example, a drawing or a 3D-modelling program (a picture, for example). Then use DirectDraw or Direct3D (where appropriate) to display this drawing/scene on the display.
Naturally, in order for this to work, you must also set up an event-map for the display. In DirectX, this event-map is also created manually. You can only monitor for events fired on input devices (such as a mouse click), and then use a reference drawing to determine if the mouse was over an object/piece-of-drawing that causes some event.
For a compete example on the matter, see a set of GameDev.Net hosted articles. A link to the article list is provided here. See the first topic "Implementing a GUI using C++ and DirectX". Alternatively, use this link to download the entire documentation as an RTF file for off-line reading.
The article writer assumes that you have a solid basis in C++, Win32 API and the event-driven system that operates behind Windows OS Family. If any of these is lacking, you'll find the article series difficult to understand.
Also, for future reference, for all your game programming needs, first consult the VERY comprehensive article list of GameDev.Net.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I have take this sample program at microsoft.com
ms knowledgebase 238228 how to create office2000com addin in vb
and trying to create addin for office application. I am using the sample with
IDTExtensibility2. the problem is when using this sample i can't get the event to DocumentBeforeSave,DocumentBeforeClose some how
anyone has sovled this problem?
Shin
|
|
|
|