|
I have an app which as soon as I try and start it Windows 98 gives me "Could not execute. Program has incorrent format (Win32 Error 11)" when running. Then a second MsgBox "The MyApp.exe file appears to be corrupt. Reinstall the file, and then try again."
The same .exe works fine on Windows 2000 and used to work fine on W98.
I am at loss as to the cause and how to resolve it. I have added two new static libs recently and will work through the code and remove all calls to them and see if the problem goes away. I was using VC6 SP3 and have just upgraded to SP4, then did clean builds and still have the same problem.
Help.
Neville Franks, Author of ED for Windows
http://www.getsoft.com
|
|
|
|
|
Just an idea...
Do you use any UNICODE strings?
If you do, win9x get's kinda mad at you
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi Anders,
Thanks for that. Your comment was just enough to point me in the right direction. I've recently added an RCDATA resource which is a string of 110 characters. This is causing the problem but so far I don't know why. It doesn't seem to be the length, as splitting it in two still causes the problem. I'll keep looking. Its great that this works fine on Windows 2000, but breaks Win98.
Thanks again.
Neville Franks, Author of ED for Windows
http://www.getsoft.com
|
|
|
|
|
Hi there,
I've got a dialog based MFC application that I wish to make resizable. The problem is that I have a CListCtrl and everytime I try to resize it in my overridden OnSize method using either SetWindowPos of MoveWindow my application complains. I trace the error to the IsWindow ASSERT in the SetWindowPos or MoveWindow function.
Since I've only recently moved to MFC from the relative ease of VB (where I'd just set the width and height porperties and be done with it) I'm feeling somewhat confused
Thanks in advance.
Marc
|
|
|
|
|
There are a few classes on this site that already do what your tring to acomplish;
http://www.codeproject.com/dialog/resizabledialog.asp
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Sometimes, I have noticed your program can get some WM_SIZE messages quite early, prior to the child controls being truly created. You can test the window handle of your child controls for IsWindow() to be valid prior to moving them around in the WM_SIZE, and that might help.
|
|
|
|
|
I have an old C code i want to interface to my MFC program. I have put this code in a static library. But when i call this code within a dialog box my keyboard becomes inactive and i cannot close my dialog box until th c code is terminated. I have put a cancel button which should stop my c code. But since i have no control the cancel button is only activated at the end of the c code.
I should use CreateProcess with perhaps 2 threads one for my c code and the second for the interface input, but i dont know how.
Can somebody help me ?
dezai
|
|
|
|
|
I am not quite sure if you need help with creating a thread or with creating a process. The sample code below should help you to create a process.
BOOL CreateProcess(const CString& strDir, const CString& strApp, const CString& strCmdLine)
{
BOOL bRetCode;
VERIFY((strApp.GetLength() < _MAX_PATH));
VERIFY((strDir.GetLength() < _MAX_PATH));
VERIFY((strCmdLine.GetLength() < _MAX_PATH));
char szAppBuf[_MAX_PATH]; memset(szAppBuf, '\0', _MAX_PATH);
char szCmdBuf[_MAX_PATH]; memset(szCmdBuf, '\0', _MAX_PATH);
char szDirBuf[_MAX_PATH]; memset(szDirBuf, '\0', _MAX_PATH);
STARTUPINFO startup;
PROCESS_INFORMATION processInfo;
startup.cb = sizeof (STARTUPINFO);
startup.lpReserved = 0;
startup.lpDesktop = NULL;
startup.lpTitle = NULL;
startup.dwX = 0;
startup.dwY = 0;
startup.dwXSize = 0;
startup.dwYSize = 0;
startup.dwXCountChars = 0;
startup.dwYCountChars = 0;
startup.dwFillAttribute = 0;
startup.dwFlags = 0;
startup.wShowWindow = 0;
startup.cbReserved2 = 0;
startup.lpReserved2 = 0;
strcpy(szAppBuf, (LPCSTR) strDir);
strcat(szAppBuf, (LPCSTR) strApp);
strcpy(szDirBuf, (LPCSTR) strDir);
strcpy(szCmdBuf, " "); //For some reason CreateProcess
//requires more than 1 space padding around command line
if (strCmdLine.GetLength() > 0)
{
strcat(szCmdBuf, (LPCSTR) strCmdLine);
}
bRetCode = ::CreateProcess(
(LPCTSTR) szAppBuf, // pointer to name of executable module
(LPTSTR) szCmdBuf, // pointer to command line string
NULL, // pointer to process security attributes
NULL, // pointer to thread security attributes
FALSE, // handle inheritance flag
0, // creation flags
NULL, // pointer to new environment block
(LPCTSTR) szDirBuf, // pointer to current directory name
&startup, // pointer to STARTUPINFO
&processInfo // pointer to PROCESS_INFORMATION
);
if (bRetCode == TRUE)
return TRUE;
return FALSE;
}
Gaulles
|
|
|
|
|
Something like the folowing might help you out.
...
STARTUPINFO StartupInfo;
if ( CreateProcess ( , &ProcessInfo ) ) {
for ( ; ; ) {
if ( WAIT_OBJECT_0 == WaitForSingleObject ( ProcessInfo.hProcess, 0 ) ) {
break;
}
if ( m_bStopped ) {
TerminateProcess ( ProcessInfo.hProcess, 0 );
}
PeekAndPump ();
}
}
...
void PeekAndPump ()
{
CWinApp * pApp = AfxGetApp ();
MSG msg;
while ( ::PeekMessage ( &msg, NULL, 0, 0, PM_NOREMOVE ) ) {
pApp->PumpMessage ();
}
}
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
How do you trap the window close button (the X in the upper right hand corner of the frame) I want to pose a question to the user before the frame closes.
Thank you,
Brad
|
|
|
|
|
Handle the WM_CLOSE message. This also gets sent if the user hits Alt+F4, if that's important.
--Mike--
http://home.inreach.com/mdunn/
#include "buffy_sig"
|
|
|
|
|
Thank you. I thought I tried that but obviously I did not. Works great.
Brad
|
|
|
|
|
ActiveX control (COleControl) as property in other ActiveX control?
|
|
|
|
|
Hi,
I am trying to write a proxy server but have run into a major problem. When
i try to read from a connected socket, it reads a couple of times and then
i get a connection reset from peer error in the errno var. Below is a
portion
of the code. Can anyone tell me what i am doing wrong?
if (write(sockfd, tempBuffer, sizeof tempBuffer) < 0)
errexit("echo write: %s\n", strerror(errno));
bytesReceived = read(sockfd, buf, sizeof buf);
if (write(fd, buf, sizeof buf) < 0)
{ errexit("echo write: %s\n", strerror(errno)); }
/* Is it a html page or image file */
headerResult = CheckHeader(buf);
if (headerResult == 0) /* html page */
{
while (bytesRead > 0)
{
bytesRead = read(sockfd, buf, sizeof buf);
if (write(fd, buf, sizeof buf) < 0)
{ errexit("echo write: %s\n", strerror(errno)); }
}
}
else
{
while ((bytesReceived < headerResult)&&(bytesRead > 0))
{
bytesRead = read(sockfd, buf, sizeof buf);
if (bytesRead < 0)
{ errexit("echo read: %s\n", strerror(errno)); }
bytesReceived = bytesReceived + bytesRead;
if (write(fd, buf, sizeof buf) < 0)
{ errexit("echo write: %s\n", strerror(errno)); }
}
}
shutdown(fd,1);
close(sockfd);
--------------
http://www.SaudiABM.com
|
|
|
|
|
I’m a new user in Microsoft Visual C++ and I’m having a problem using SQL and stored procedure. I’m trying to create a new application using ODBC but the menu new stored procedure in DataView was disabled (not active), so I can’t create new procedures. For information, I use Pervasive.SQL Database.
So I was wondering whether anyone can tell me how to create new procedures and connect it to Visual C++, or are there any other way on using and executing SQL commands in Visual C++ ? And, can I have some example as well ?
Thank you for your help.
Kathrin
horas
|
|
|
|
|
nobody answer my question, did my question too difficult or too easy?
Kathrin
|
|
|
|
|
You might want to look at the docs for SQLExecDirect in the MSDN.
|
|
|
|
|
I want a class to have a member variable: PAVISTREAM *m_pavistream. Visual C++ does not share my viewpoint, and gives me many errors in the .h file:
syntax error : missing ';' before '*'
error C2501: 'PAVISTREAM' : missing storage-class or type specifiers
error C2501: 'm_pavistream' : missing storage-class or type specifiers
However, this works fine when I have the stream as a local variable. I'm not seeing what's wrong with this declaration. But then again, I don't know anything about the stream interface, so that could be my problem Ideas?
thanks-
jake
|
|
|
|
|
Ditch the P in front of it and make it IAviStream * m_pAviStream. Also, don't forget to include VFW.h and link with VFW32.LIB
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
I am developing a program that resides in the system tray and want it to start hidden. But, I am having a slight problem. I know how to start with the main window hidden, that's the easy part. The part that I'm having trouble with is that when I start the program you can see the main window flash for a split second. I've tried removing WS_VISIBLE from the mainframe, SW_HIDE on m_pMainWnd in theApp class, adding WS_ICONIC to the mainframe style, but no go. Any help on this is greatly appreciated.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
try to resize the window to zero by using the method call MoveWindow(...)
Good luck.
|
|
|
|
|
This is a wierd situation, and the solution is even wierder. I had to do this in an app a while ago and it took me a while to solve it.
Change this:
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
To this:
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
And add this:
m_nCmdShow = SW_HIDE;
Right before you register your doc templates.
Hope this helps,
Frank
|
|
|
|
|
Thanks for the info. It surprisingly worked, somewhat. It does start hidden but when the listview refreshes the first time (2-3sec after startup) it flashes on screen. I don't see why the m_nCmdShow is any different than just passing it a simple SW_HIDE but it works better. Thanks.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Ok, after further analysis I've discovered the problem. After the view refreshes I have a function called ProcessReminders() and in it if a reminder has the dialog option set that means show the window. I call showwindow on the mainframe ((CMainFrame*)AfxGetMainWnd())
and pass it SW_SHOW which causes it to be shown but then the app hides it do to the SW_HIDE value of m_nCmdShow. If I comment out the showwindow line everything starts up how I want it to, but if a reminder is set to show the window I need it to show.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Cool...glad you got it working the way you wanted.
Cheers!
Frank
|
|
|
|