|
Hi all. What would be a way to program a code that created txt files in any dir after %systemroot% ?
For example. If you were to type cd %systemroot% in an XP command line, then you would get sent to C:\WINDOWS - Im trying to find out a way to create files in that directory, no matter the drive. Ive tried the following code:
<br />
#include <fstream><br />
using namespace std;<br />
<br />
void main(){<br />
ofstream file;<br />
file.open("%systemroot%\\test.txt");<br />
file << "This is only a test." << endl;<br />
file.close();<br />
}<br />
And nothing happens. So i switched %systemroot% to %windir% from another persons example, and it didnt work either. So i was hoping maybe im using a wrong character. (ie: %) Maybe if im using another character then i'll succeed. Any suggestions will be greatly appreciated. Thanx in advance!
|
|
|
|
|
Call ExpandEnvironmentStrings() to expand those variables.
|
|
|
|
|
|
Try this:
ofstream file;
char Pathname[MAX_PATH];
::ExpandEnvironmentStrings("%systemroot%\\test.txt", Pathname, MAX_PATH);
file.open(Pathname);
file << "This is only a test." << endl;
file.close();
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanx Mark, that worked just fine however i had to change a few things, but the general idea did help me grasp the meaning of the situation. Now i dont have to guess what the drive is ever again
Thanx again!
|
|
|
|
|
Hello,
I am writing an application that communicates with an external device using a USB port. I have the USB driver for the device, but I want to automate the installation of the driver inside the application so the user does not have to install the driver manually. I have embedded the INF and SYS files in the application, so that when the application starts, these files are written to the hard drive. Once the files are on the hard drive, I want the app call whatever windows functions there are to install the driver.
The easy method would be to copy the driver to the system32 directory and let the wizard install it when the device plugs in, but I hate wizards and don't want the user bothered by it.
I have not yet been able to get the driver installation to work. I have tried doing a ShellExecute of RunDll32.exe with the command line info pointing to the INF file, but I never see the driver get installed into the system32 directory. When I plug the device into the PC, Windows does not recognize it.
Any ideas? Is there another way of doing this besides Shelling RunDll32.exe?
|
|
|
|
|
The Setup functions are used to install stuff. Going this route is a bit complicated, though, since the documentation on SetupXxx is not the best. It would be much easier just to let the install hardware wizard do its thing, but if you insist, research the Setup functions.
Judy
|
|
|
|
|
Hi all,
I am sorry but its really urgent and I hope u will help me.
I use SendInput API function to emulate keystrokes like this:
void CKeyboardInput::KeyDown(WORD wVK)<br />
{<br />
INPUT inKB;<br />
<br />
::ZeroMemory(&inKB,sizeof(INPUT));<br />
<br />
inKB.type=INPUT_KEYBOARD;<br />
inKB.ki.wVk=wVK;<br />
<br />
SendInput(1,&inKB,sizeof(INPUT));<br />
<br />
}
The code runs perfectly with all normal windows applications, however, this code doesnt work for some types of programs like Games, for example I want to send a key to move a car in Need for Speed II or in Driver but I failed to get it to work.
Anybody can point out any useful comments? why dont these apps respond to SendInput calls? and is there any workaround?
Waiting for good news
Thanks
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Games probably use DirectInput hence SendKeys cannot work.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thanks for ur reply,
But is there any solution for this? how can I send keystrokes to a game?
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
I think there is no solution. But I'm not an expert about.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi,
I have about 3 Megs of data coming in at intervals of about 100 times a second. I am trying to write this into the harddrive so that I can do some post processing after all the data is written to a file. I am finding that the hard drive cant keep up and it actually causes data to be dropped. So what I did was implemented a queue where I can put into memory and then I wrote another thread to copy off the data to the harddrive but that is still not doing the trick. The memory writes are way too quick and my circular queue gets full before the hardrive writes are done, so then the thread needs to wait.
I need to be able to record this data for a large amount of time, say about 1 to 2 hours without losing any data. I get loss of data within 10 seconds. I am going crazy here, if there is another approach to doing this I am all ears, even if it calls for a full overhaul of my application, or if there is something else I am doing wrong.
All the code is written in C++.
Thanks in advance
|
|
|
|
|
Two questions:
1) Where is your data coming from?
2) Is your hard drive physically capable of that data rate?
|
|
|
|
|
1.) the data is coming from a DAQ Board
2.) I dont know the datarate of the hard drive.
Is there a way to do this without using the harddrive?
Thanks
|
|
|
|
|
godspeed123 wrote: Is there a way to do this without using the harddrive?
Not and keep your "I am trying to write this into the harddrive so that I can do some post processing after all the data is written to a file." requirement.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for the response.
So that means I am screwed, lol. Is there any other approach that I can use to get around this, even if it means rewriting all the code.
|
|
|
|
|
Hello,
Are you saying 3MB x 100 times/second = 300MegaByte/sec? If this is the case, you need some special hard drives, i.e. SAS or SCSI 15K rpm, in RAID 0 with 4 or 6 such drives. Then it may be possible to capture data without lose.
Conventional single 7.2K rpm desktop drives only can maintain ~50MegaByte/sec and you need to pay attention on that.
Hope it helps.
|
|
|
|
|
We too ran into a similar problem. We are streaming video over USB 2.0 from a cell phone to a PC as the device plays a video or pans with camera. We ran into a problem where the system could not keep up. So we tried using a memory mapped file instead of using the old standard CreateFile() and WriteFile(). That did speed things up to where we could capture data at 40 frames a second but we still have an issue at 80 fps.
|
|
|
|
|
Hmmm my stuff is coming in at about 100 times a second, I will give it a shot, but as you guys did I'm sure I will hit the same pitfalls. Is there anything else you tried that worked?
Thanks again.
|
|
|
|
|
No. That's the best solution we found for speed.
|
|
|
|
|
godspeed123 wrote: I have about 3 Megs of data coming in at intervals of about 100 times a second.
You are receiving 300MB of data every second? I'm not sure of any HD that can write that fast.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I think by 3 Megs, he means 3 MB.
Shog on learning VB6: Ah, that would have been VB6. Kicked my ass anyway. So easy to learn, just like falling down a flight of stairs...
|
|
|
|
|
brahmma wrote: I think by 3 Megs, he means 3 MB.
No kidding. I've never known "megs" to mean anything other than MB.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: You are receiving 300MB of data every second? I'm not sure of any HD that can write that fast.
The above quote is from your previous post. I did not reply to tell megs is MB, but I said the OP meant 3MB and not 300 MB.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
brahmma wrote: ...the OP meant 3MB and not 300 MB.
Last time I checked, 3MB 100 times per second was equal to 300MB per second.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|