|
Ah, good eye!
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
its a she btw
|
|
|
|
|
Check your return values - you're not checking whether the fopen() calls succeed.
Run the program in the debugger (F5) and when it crashes, the debugger will show you exactly where it's happening.
|
|
|
|
|
i took out the "if (!fp) {..} " because it was not giving me any errors and it makes the posted code shorter to find the error. My original script has it and the error is not there, however I did the F5 run and it surprisingly ran untill the end. the output of the debugger is the following
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\user32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\gdi32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\advapi32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\ole32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\comctl32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\MSCTF.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\oleaut32.dll', no matching symbolic information found.
Loaded 'D:\Archivos de programa\Internet Download Manager\idmmkb.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\clbcatq.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\comres.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\version.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\shell32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\shlwapi.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\setupapi.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\linkinfo.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\ntshrui.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\atl.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\netapi32.dll', no matching symbolic information found.
Loaded 'D:\WINDOWS\system32\userenv.dll', no matching symbolic information found.
The thread 0xE8 has exited with code 0 (0x0).
The program 'C:\p123123123123123123\asdasdasd\installer\Debug\installer.exe' has exited with code 0 (0x0).
however the .exe file still gives me the same error.
Chichilina
|
|
|
|
|
I suspect it's your call to GetCurrentDirectory, which will return different values when you run in debug mode versus executing the .exe directly, through explorer or a shortcut icon. I could be wrong of course....
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Thank you and everybody for the help. I just made a new script excluding all the rest of the stuff to figure out wth is going on. Here the complete script:
#include "stdafx.h"
#include <stdio.h>
void binedit (char *cur_dir) {
FILE *fp,*fp2;
char filename[256],filename2[256];
int temp,cur_bit=0;
sprintf(filename,"%s\\file1.bin",cur_dir);
sprintf(filename2,"%s\\file2.bin",cur_dir);
fp=fopen(filename,"rb");
if (!fp) {MessageBox(NULL,"error filename","a",MB_OK);return;}
fp2=fopen(filename2,"wb");
if (!fp2) {MessageBox(NULL,"error filename2","a",MB_OK);return;}
temp=(int)fgetc(fp);
char a[256];
sprintf(a,"%s %d",filename2,strlen(filename2));
MessageBox(NULL,a,"param",MB_OK);
while (!feof(fp)) {
switch (cur_bit) {
case 650:fputc(1,fp2);break;
case 651:fputc(2,fp2);break;
case 652:fputc(3,fp2);break;
case 653:fputc(4,fp2);break;
case 654:fputc(5,fp2);break;
case 655:fputc(6,fp2);break;
case 656:fputc(7,fp2);break;
case 657:fputc(8,fp2);break;
case 658:fputc(9,fp2);break;
case 659:fputc(10,fp2);break;
case 660:fputc(11,fp2);break;
case 661:fputc(12,fp2);break;
case 662:fputc(13,fp2);break;
default:fputc(temp,fp2);
}
cur_bit+=1;
temp=(int)fgetc(fp);
}
fclose(fp);
fclose(fp2);
unlink(filename);
rename(filename2,filename);
}
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
LPSTR lpCmdLine,int nCmdShow) {
char *cur_dir;
cur_dir=new char;
GetCurrentDirectory(512,cur_dir);
binedit(cur_dir);
return 0;
}
I run this exe from the explorer in "C:\p1231231\asdasdasd" without any problems. if i add a 2 to the first directory "C:\p12312312\asdasdasd" I still have no problems. However if I changed it to "C:\p12312312123123123123\asdasdasd" I get a crash. I do not understand.
Does the other ppl who r trying to help me also receive this POST? or do I have to reply him as well with the code also. Sorry but I'm noob in this.
Chichilina
|
|
|
|
|
char *cur_dir;
cur_dir=new char;
GetCurrentDirectory(512,cur_dir); Not sure if this is causing the crash, but that code is wrong - you're only allocating one char but you're telling GetCurrentDirectory() that you allocated 512. This is a buffer overrun bug and GetCurrentDirectory() will end up writing to random memory, which may be corrupting the CRT enough to make fopen() crash.
(BTW, everyone can see the whole thread, this one reply is just fine, welcome to CP )
|
|
|
|
|
hrmmmm, i feel so dumb !!! ty ty ty
i think i need eyeglasses or something. that did solve the problem.
thank you all for your time, and sorry for this. Next time i'll make and extract like i just did, right at the beginning, so i don't waste all of your time with my brainfarts.
Chichilina
|
|
|
|
|
chichina wrote: Does the other ppl who r trying to help me also receive this POST?
No, but they'll see it if they are interested.
chichina wrote: I run this exe from the explorer in "C:\p1231231\asdasdasd" without any problems. if i add a 2 to the first directory "C:\p12312312\asdasdasd" I still have no problems. However if I changed it to "C:\p12312312123123123123\asdasdasd" I get a crash. I do not understand.
Yeah, that's pretty weird. I've tried a bunch of different folders and they all work for me.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
I assume that the code where you get the current directory name looks something like the following:
char szBuffer[512] = "" ; // <- this buffer is big enough, right?
GetCurrentDirectory(512, szBuffer) ;
I agree with Mr Dunn that there must be a buffer overrun going on somewhere. Such overruns often don't occur when running in debug mode, then rear their ugly head in a release build.
Scott
|
|
|
|
|
yes, ty, the problem was solved
char *cur_dir;
cur_dir=new char[512];
strangely the overflow only occured when strlen(filename) > 39/41 characters long, which mislead me on where to look for the error.
chichilina
|
|
|
|
|
Hello every body.I'm from Thailand and this First time to visit this website. ....
I want to Made Soure code Crc 10 by c++. Program can calculate Crc10 to input binary(bit for check) and out put binary too .please help me how to made it.
Thanks...
|
|
|
|
|
what is the simplest way to get the output of a cmd window into a dialog?
mfc VC++ 6
-- modified at 22:07 Saturday 18th November, 2006
|
|
|
|
|
CHeck out this article[^], the sample code runs a console app and reads the output.
|
|
|
|
|
In my memory,i think PIP2 can catch the output of cmd app's message.....
|
|
|
|
|
I would need to have a different spacing between lines in a multiline edit box, but I can't find anything. I can change the spacing between character, but not lines. Is there anything that could do this?
|
|
|
|
|
Besides rolling your own edit control, you could use a ES_MULTILINE Rich Edit (2.0+) control and
set the line spacing with the EM_SETPARAFORMAT message using the PARAFORMAT2 structure.
It may be over-kill for your needs but it works
|
|
|
|
|
Seems a bit too much to go now and change all the Edit controls to Rich Edit and so on. So I guess I'll leave everything as it is and no line spacing this time
|
|
|
|
|
Sorin Basca wrote: Seems a bit too much to go now and change all the Edit controls to Rich Edit and so on.
It's actually not too bad since Rich Edit controls work with the same messages as standard
edit controls. They sure have alot of stuff you may not need though!
Mark
|
|
|
|
|
I have a problem with passing function pointer as lParam. I get an error message like that: error C2440: 'type cast' : cannot convert from 'void (__thiscall Screenshots::* )(void)' to 'LPVOID'
how to fix that?
Screenshots::Screenshots()
{
void (Screenshots::*ScrLoopPtr)(void);
ScrLoopPtr = &Screenshots::ScrLoop;
hookHD = CreateThread(0, 0, mThread, (LPVOID)ScrLoopPtr, 0, 0);
}
thanks for help
|
|
|
|
|
Whats the purpose of this line?
void (Screenshots::*ScrLoopPtr)(void);
Is your Screenshots::ScrLoop function declared as static?
Try this
typedef void (Screenshots:: ScrLoopPtr)( void );<br />
ScrLoopPtr = &Screenshots::ScrLoop; <br />
hookHD = CreateThread(0, 0, mThread, (LPVOID)ScrLoopPtr, 0, 0);
|
|
|
|
|
it was simpler than i thought
ScrLoop was not static so i declared it as static and passed its pointer like that CreateThread(0, 0, mThread, &Screenshots::ScrLoop, 0, 0);
|
|
|
|
|
Hi
I am reading some documents about win32 programming.And try to understand its event procedure.
For windows controls which i added to my application.When an event occurs windows add a msg to its msg tail.But also send WM_COMMAND msg to my application so i can do something when that event occurs.
For example for button click event:
Message:BM_CLICK
Notification:BN_CLICKED
(I hope i am right until now)
But i looked other controls mesg and notification lists.They don't match.I mean there is not notification for every message.
For example combobox have CB_ADDSTRING mesage, but it does not have CBN_ADDSTRING notification.
But why?
What is the concept for notification and messages, what is the differnces between them?
I hope i can explain my question well, i am trying to understand win32 event procedure fully when an event occurs.
I am looking for your answers.
Thanks..
|
|
|
|
|
One more question.
When an event ocuurs for example button clicks.
Which one is first doing by OS.
Notification or msg?
I mean, first windows put msg to msg tail of button control and put WM_comaand msg to my application.Or reverse order?Which one is first?
|
|
|
|
|
The best thing to do is use spy++ (comes with VC6) to watch the messages in a window. In Visual Studio, click 'Tools' from the menu and then click spy++. Use this tool to first find a window, then watch it's messages. You can start clicking buttons in the window to watch which messages are being sent and recieved.
|
|
|
|
|