|
Im going to make a console project... don't ask... and I need to add command line arguments, im using windows xp, and somehow when I add the command line arguments to the end of the filename e.g. somefile.exe /something it says "/" and a bunch of other characters aren't alowed to be used... has windows xp completely taken off command line arguments?? sry its just that the last time I had command line arguments to one of my programs was when windows '98 came out.
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
#include <stdio.h>
int main(int argc, char** argv)
{
for (int i = 0; i < argc; i++)
printf("Arg %d = %s\r\n", i, argv[i]);
return 0;
}
This small C program will dump the args. The process of receiving args for console apps hasn't changed a bit
|
|
|
|
|
Oh yeah. If you're wanting a string with spaces, enclose them in quotes to get a single argument, e.g., long filenames with spaces:
<nobr>someprog.exe /v /n:5 "c:\my program data\my file data.txt"
The above yields 3 arguments passed to someprog.exe, plus somearg.exe itself.
arg0 = someprog.exe
arg1 = /v
arg2 = /n:5
arg3 = c:\my program data\my file data.txt
|
|
|
|
|
are you doing this on windows xp.. because for me it says / and some other characters are illegal to use
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
Hi!
I face a trouble, pls help me.
I wanna write a plugin for photoshop, but it call my plugin dll with a HFILE handle. But I should know the filename. Is there any way to get the file name from HFILE?
Thank you!
|
|
|
|
|
|
I have written a sample application to catch the WM_DEVICECHANGE message and it works well.
Now I tried to move the same functionality into a service so I create the service and the service creates an instance of a class which I defined that extends CDialog (called CMessageHandler).
CMessageHandler m_MessageHandler;
m_MessageHandler.Create(HIDDEN_DIALOG, NULL); {This returns TRUE, I checked}
CMessageHandler is supposed to handle WM_DEVICECHANGE event but it doesn't. I have declared it in the message map and I have created the necessary OnDEviceChange function but the messages never seem to be caught. I'm sure I'm doing something really stupid here.
Any help would be greatly appreciated.
|
|
|
|
|
have u checked the service actually receives messages?
"there is no spoon" biz stuff about me
|
|
|
|
|
I had posted a question in this forum earlier and was told that a service could receive messages indirectly if I created a window to handle the messages.
Would a window normally start receiving messages after the Create() method is called or should it be visible in order for it to receive messages?
Am I creating it right?
Thanks for your help
|
|
|
|
|
Hello there. I have read a message that you posted in this forum that u have written a sample application to catch the WM_DEVICECHANGE message and it works well.
I was wondering if you could e-mail to me a sample of the above application as I am interested in implementing that same function.
Also, would you happen to know of any working samples/examples that have implemented the OnDeviceChange() function? If you do, it would be great if you could lead me to/send me those sources. I hope u can help.
RaYDyO
|
|
|
|
|
Why does this take thirty or more seconds to run on a 1.5ghz 128mb machine?
Also when it runs this section of code (without sleep(1) after the addition) it brings the CPU up to 99 (its running in a thread)
This really makes no sense
It runs through somewhere between 7000 to 8000 entries:
CString m_strNewWordSection;
for (i=0; i<arWLSize; i++)
{
m_strNewWordSection+="\r\n\t<word_data><word>"+
m_caWordList.GetAt(i).m_strWord+"</word><scores>"+
m_caWordList.GetAt(i).m_strScores+"</scores></word_data>";
}
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
CString::+= is s-l-o-w Try writing to a TCHAR[] (of a predetermined large size) and then assigning it to the CString , a la:
TCHAR szNewWordSection [MAX_WORD_SECTION];
_tcscpy (szNewWordSection, _T(""));
for (int i=0; (i < arWLSize; i++) {
_tcscat (szNewWordSection, _T("\r\n\t<word_data><word>");
_tcscat (szNewWordSection, m_caWordList.GetAt(i).m_strWord);
_tcscat (szNewWordSection, _T("</word><scores>");
_tcscat (szNewWordSection, m_caWordList.GetAt(i).m_strScores);
_tcscat (szNewWordSection, _T("</scores></word_data>");
}
CString m_strNewWordSection = szNewWordSection; Btw, there's nothing wrong with it pegging the CPU, since the code is compute bound (allocating memory and copying data).
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
The problem is the word size is unknown it can get upto 80 (thats really kahrazy but its possible) and teh scores can get large. In the data set I'm using no word gets over 20 max and no set of comma seperated scores gets over 40 but these figures change with the data set thats the problem with something thats not dynamic.
The problem I have is when its hitting the roof with the cpu is with machines less powerful than mine is also the users that this is going to be run on.
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
You should probably be using XML4C (or MSXML), Steven. Just build the DOM in memory, then write it out to a file. XML4C is f-a-s-t as hell.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
No, I really don't need it. I think now it may be a good idea to put it together in blocks, I think the problem its trying to keeping adding more and more to an increasingly large string (500kb) and it just gets slower cause it does it soomany times. CString has a bad problem about stuff >100kb.
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
(i assume you are using CArray cause I see xxx.GetAt(i))
Try std::vector or std::list instead of CArray.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
just a thought....
* remove the automatic bufferlock form the CString
* set the size to a realy BIG value
* add the data
* calculate the new size.
m_strNewWordSection.GetBufferSetLength(50000);
for()
{
do stuff
}
m_strNewWordSection.GetBufferSetLength(-1);
|
|
|
|
|
|
When you asked the question a few days ago, I suspected that this would be the issue.
In general, every += operation (including the str+str) operations will result in a memory allocation, two string copies and a memory deallocation. So for 8000 entries, there will be 5 of these per entry. That is 40000 memory allocations, 80000 string copies and 40000 memory deallocations.
The previous poster (if it works, I didn't know you could do that ), reduces the problems down to 1 memory allocation, 40000 string copies and 1 memory deallocation.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hello,
I have the following class structure:
_________________ ________________
| | | |
| ComponentPeer |<-----------| Win32Component|
|________________| |________________|
Î Î
| |
_________________ ________________
| | | |
| ContainerPeer |<-----------| Win32Container|
|________________| |________________|
Î Î
| |
_________________ ________________
| | | |
| Window Peer |<-----------| Win32Window |
|________________| |________________|
Î Î
| |
_________________ ________________
| | | |
| Frame Peer |<-----------| Win32Frame |
|________________| |________________|
All the classes on the left are pure interfaces.
On the right I have abstract classes. The only concrete class is Win32Frame. Win32Component contains a member variable hWnd. Well, if I have a pointer declared as ComponentPeer * which points to a Win32Frame instance I'm unable to get the correct value for hWnd. For example:
ComponentPeer *cp = new Win32Frame();
Win32Frame *ab = dynamic_cast<Win32Frame *>(cp);
HWND hWnd = ab->hWnd;
this code crashes sometimes with an exception (illegal memory access) or my hWnd has not the correct value. Why doesn't it work? Is there any error? And how could I make it work? (I don't want to have a getHwnd method in my multiplatform class componentPeer).
Thanks.
|
|
|
|
|
Weird, that looks alot like the VCF's class layout.
I don't want to have a getHwnd method in my multiplatform class componentPeer
Well you could do what I did:
VCF::ControlPeer
just have a method called getHandleID (or something like that) and return an unsigned long. Then typecast that to an HWND.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Jun Misugi wrote:
Win32Frame *ab = dynamic_cast(cp);
HWND hWnd = ab->hWnd;
Warning! Danger! If you call dynamic_cast, you may get back a NULL if its argument could not be casted to the right class. So always check for NULL in this case.
Remember, even if you win the rat race, you're still a rat.
|
|
|
|
|
Ok, I have found the problem. I just had to select the option "General-Purpose always" instead of the default "Base-Cast Always *" in Project/Settings/C/C++/C++Language RepresentationMethod.
I don't know what this stuff means but it makes it work correctly. Does anyone know anything about it?
Thank you anyway for answering.
|
|
|
|
|
I am trying to track down a crash on application exit that causes the program to dump in _free_dbg_lk. This memory deallocation is called from a third party component that I have been using for a while without a problem. I am trying to determine what I changed that is now causing the app to dump on exit.
I know about "no mans land" (0xFD), dynamically allocated but uninitialized memory (0xCD), dynamically allocated and freed memory (0xDD). In this problem the pointer is 0xFEEEFEEE, which I have also seen plenty of times when debugging memory allocation problems.
My question is: Does anybody know what causes a pointer to be changed to 0xFEEEFEEE? This should help me track down what is messing up my application shutdown.
|
|
|
|
|
i need some help in getting data from a txt file to an array. i'm using C++ in visual studio .net. and yes i'm a newbie and this is a homework assignment so please be easy on me hahaha...
here's the txt file contents:
75 83 77 91 76
80 90 95 93 48
78 81 11 90 73
92 83 30 69 87
23 45 96 38 59
60 85 45 39 67
27 31 52 74 83
93 94 89 77 97
79 85 28 93 82
85 72 49 75 63
i need to use the numbers in the file for calculations. here's part of my code using StreamReader to get the data from the txt file.
Code:
<br />
int main() <br />
{ <br />
double average = 0.0; <br />
int rows = 0; <br />
int cols = 0; <br />
<br />
IO::StreamReader *inData; <br />
inData = IO::File::OpenText("InData.txt"); <br />
<br />
while (inData->Peek()) <br />
{ <br />
} <br />
inData->Close(); <br />
this is where i get tripped up.. i'm unsure what i need to add to get that data into an array to do calculations. I know i still need to declare the array. i just need to know what do to in the while loop to get the data from the txt file into an array to do calculations. so i guess the data from the files also need to be converted to integers i guess right?
K
|
|
|
|