|
I think I finally figured it out... I am using VC++ .NET and I get the exit info from the output window. The EXE was exiting with code 3, not the win32 thread of my app (WinMain). I kinda gave up on the exit code 3 thing, and decided to check if my app had any memory leaks. It did. I tracked down the memory leak, ran the program and it exited with code 0. ... So, I think your first post was correct. The program was exiting "abnormally". Thanks.
|
|
|
|
|
it may be due to the way you are exiting the program.
if you use
PostQuitMessage(WM_QUIT)
you should not have any problem
|
|
|
|
|
I am actually exiting with PostQuitMessage (0)... I tracked the problem down to be a memory leak, and the program was exiting with an "abnormal termination" exit code. The memory leak wasnt crashing the program or throwing an exception, which it should have... Thanks.
|
|
|
|
|
Hello:
I have a VC++ 6.0 executable program that only has one screen, such as control panel, it has many buttons and a displayable field. Depending on the buttons pressed, the program reads, validates, generates complex reports of ascii, or access files. Many guys use this program so I installed this in every PC that needs this program. For the other side, I am interested to know about WEB programming and apply the necessary changes to my program so it would not be necessary to distribute it in every PC.
However, because I am a novice, I have the next questions:
1. What things should I consider before modification of in my program so it can be WEB enabled?
2. In which moment should I use a complementary WEB programming languaje such as JAVA?
3. Is there a Web site which could help me more with my case?
Thank you for your help!
|
|
|
|
|
Hi
why does the following function not work:
<br />
static bool bStatus = false;
<br />
void somefunction()<br />
{<br />
bStatus = true;<br />
}<br />
<br />
void main()<br />
{<br />
bStatus = false;<br />
somefunction();<br />
}<br />
<br />
At the "now bStatus should be true, right?" should bStatus be true, but it ISN'T!!! Anyone knows why not? What could it be? In normal C++ (MSVC++) the code above works normally.
But when using the C++ for the C165-board programming language (i use C165 in a mini-robot). As compiler the GNU-CC compiler is used.
|
|
|
|
|
Not knowing anything about C165, i prolly can't help you; the code looks correct to me. But,- How are you checking the value of bStatus? Your comment indicates that you are somehow, but doesn't specify.
- There's nothing "special" about bStatus, is there? I.E. you're not using it in an interrupt handler or something of that sort, right?
Just a side note: it is never correct to declare main() as returning void ; always use int main(); .
Sometimes i only remember, The days when i was young Nowadays no one remembers when they were young and stupid... ADEMA, The Way You Like It
|
|
|
|
|
I check the status of bStatus using the == operator.
No interrupt handler or something modifies the bStatus variable.
Just as a side note: oops, i've written the code snippet only to show the problem. I looked it up. It is int
|
|
|
|
|
Dominik Reichl wrote:
I check the status of bStatus using the == operator.
Hmm, you mean something like this:
if (bStatus == true)
puts("All is well!");
What if you just use:
if (bStatus)
puts("ALl is well!");
Any change?
Sometimes i only remember, The days when i was young Nowadays no one remembers when they were young and stupid... ADEMA, The Way You Like It
|
|
|
|
|
No change.
Both versions do the same: the wrong thing.
Another problem. I tried the following:
<br />
...<br />
static bool bVal = false;
<br />
int main()<br />
{<br />
bVal = false;<br />
bVal = true;<br />
if(bVal == false) puts("Error");<br />
}<br />
and it shows "Error"!!! Something must really be wrong with the compiler...
|
|
|
|
|
That is very odd. If you initialize bVal to true, does it stay true?
...
static bool bVal = true;
int main()
{
bVal = true;
bVal = false;
if(bVal == true) puts("Error");
}
it does sound rather like a compiler bug.
Sometimes i only remember, The days when i was young Nowadays no one remembers when they were young and stupid... ADEMA, The Way You Like It
|
|
|
|
|
Hmm. When i don't declare the variable globally (-> declare it locally in the main() function), it works...
|
|
|
|
|
i am not sure what is in the rest of your code but i would make the following changes.
static bool bStatus = false; // global variable
int somefunction(){////////////make the function int to return values
if (condition){///////////what ever your condition is to turn bStatus true
return true;
}else{
return false;
}
}
void main(){
bStatus = somefunction();//////////////it will now return true or false
}
|
|
|
|
|
I have a save-file from my program so structured:
char id[32];
int blocksize;
:
: <- various data for an amount of 'blocksize' bytes
:
char id[32];
int blocksize;
:
: <- various data for an amount of 'blocksize' bytes
:
char id[32];
int blocksize;
:
: <- various data for an amount of 'blocksize' bytes
:
With a generic number of "DATASET_#"
When I try to load the file, I use code similiar to this:
char id[32];
int blocksize;
FILE* f;
f = fopen(filename, "rb");
while (!feof(f))
{
fread(id,sizeof(char),32,f);
fread(&blocksize,sizeof(int),1,f);
if (strcmp(id,"DATASET_1") == 0)
{
fread( );
}
else if (strcmp(id,"DATASET_2") == 0)
{
fread( );
}
else
{
fseek(f,blocksize,SEEK_CUR);
}
}
fclose(f);
When I do this, the while loop never exits if, for example, the last dataset is unknown, it seems that the fseek() function has no effect on the next "while (!feof(f))" call.
I must take care of something about fseek under NT or WinXP or I must look for an error elsewhere ?
By now, I assume the data to be written well.
Thanks in advance for any suggestion.
|
|
|
|
|
from the MSDN for fseek:
"
You can use fseek to reposition the pointer anywhere in a file. The pointer can also be positioned beyond the end of the file. fseek clears the end-of-file indicator and negates the effect of any prior ungetc calls against stream.
"
fseek doesn't care about EOF.
-c
"What the hell are you getting so upset about? I thought you didn't believe in God".
"I don't," she sobbed, bursting violently into tears, "but the God I don't believe in is a good God, a just God, a merciful God. He's not the mean and stupid God you make Him out to be".
-- Joseph Heller
Smaller Animals Software, Inc.
|
|
|
|
|
Ok, but does feof() take care of a previous fseek() ?
This loop never exits in a test program I've done... try it out plz if you can:
FILE* f;
long i;
f = fopen("c:\\a.txt","rb");
i = 0;
while (!feof(f))
{
fseek(f,i++,SEEK_SET);
}
fclose(f);
The file "a.txt" contains three simple characters.
|
|
|
|
|
Is your program C ( not C++) ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
It's C++, MFC app.
By now I have solved with something like this:
while (fread(id,sizeof(char),32,f) != 0)
{
}
But I thought that it had should exit if fseek() seeks the position over the EOF marker...
|
|
|
|
|
OK - I am curious, is there a reason you're using C functions ? What advantage do you get from fread, as opposed to C++ equivelants, souch as ifstream ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
Only because I'm in the abit of using them, so I can reuse some old code
Do you suggest me using ifstream instead ?
|
|
|
|
|
I would always recommend using C++ code over C equivelants, the C++ libraries were written not just to do the same as the C stuff, but to do it better. I was seriously asking, because I notice a lot of people posting C code and I'm happy to learn that it does some things better, better to ask and find out than wade in with my opinion and be told
Your code looked to me like it would be a lot more readable using ifstream though, although I admit I only glanced over it.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
I'm rewriting the functions using fstream, if you say fstream acts better, I trust you
Thanks for the advice
|
|
|
|
|
Hi, I have a small problem with my SDI app. There are several modal dialogs in the program. Sometimes, if I activate a different program and then press alt+tab, or even click on the program in the taskbar, only the modal dialog is brought to the foreground. The main SDI window does not appear below the dialog. This only happens when some of the dialogs are shown, but they are all created in the same way! To show the dialogs I do:
CMyDialog dlg(AfxGetMainWnd());
if (dlg.DoModal() == IDOK) {
...
}
Please help if you can. I've just spent hours searching through messages and couldn't find anyone who had a similar problem.
By the way, I'm running Windows XP, but I have the same problem under Windows ME.
Thanks!
|
|
|
|
|
Hi i need to Uninstall a program programmatically. ie. Programmatically simulating Add/Remove option from control panel .Any help ?
|
|
|
|
|
Have a look in the registry
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
There all uninstallable programs are registered.
Some notes on the keys which can be found there:
- "DisplayName" is the displayed name in the listbox.
- "UninstallString" tells you which command is executed when the user clicks the "Add/Remove" button in the control panel.
|
|
|
|
|
Hi.
I would like to change the initial location of a dialog box (modal and/or modeless.
For example, in the program I can current working on, Windows paints the the modal dialog box in th center of the program. I have to move the dialog box to the size to see the main window. I would like to change the initial location of a dialog box.
Thanks,
Kuphryn
|
|
|
|