|
I'm working in MFC. The program is dynamicly linked to in and has 3 different activex ctrl's but they didn't do any problem in the previous version.
|
|
|
|
|
Maybe there is virus in your machine
Vengeance is savage kind of justice
|
|
|
|
|
Raul Simcic wrote:
"Windows cannot run this program because it is in an invalid format!"
Does this message come from the OS or from your program? Does your program fail to work on all Windows 98 machines or just the one? Is it possible to reproduce the problem with a smaller program (i.e., create a new MFC program and add to it until the problem appears)? Have you recently installed Win32 or any AV software on the Windows 95 machine?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
The message come from the OS. I tried a few win98 machines and all of them give me the same error. I will try to reproduce a smaler program with the same error (like I said the previous version worked just fine - I set the compile parameters from the previous version but nothing).
|
|
|
|
|
Hi
I am working in MFC. In my application, I wrote a thread function which continouly checks for a update in a file in one particular directory. This thread should stop when clicked on a button. I have used ReadDirectoryChangesW for getting notification of the file change. To end the thread I waited on a STOP event i.e checking for it to end the thread.
But the m_StopEvent event is not caught beacuse the control is stuck at while( ReadDirectoryChangesW) I mean it not going inside the while loop unless ReadDirectoryChangesW returns true.
UINT CheckFileUpdates(LPVOID lp)
{
//Get the document pointer
CLogViewerAppView* pView = (CLogViewerAppView*)lp;
CLogViewerAppDoc* pDoc = pView->GetDocument();
CFileException err;
CFileStatus st;
CFile::GetStatus(pView->m_LogFilePath,st);
LONG l1,l2;
CFile file;
if( !file.Open(pView->m_LogFilePath, CFile::modeRead|CFile::shareDenyNone, &err ) )
{
TCHAR szCause[255];
err.GetErrorMessage(szCause, 255);
AfxMessageBox(szCause);
return 0;
}
l1 = (LONG)file.GetLength();
file.Close();
CFile file1;
LONG size_1 = (LONG)st.m_size;
int len = pView->m_LogFilePath.GetLength()-pView->m_LogFileName.GetLength()-1;
CString dir = pView->m_LogFilePath.Left(len);
HANDLE hDir = CreateFile( dir, // pointer to the file name
FILE_LIST_DIRECTORY, // access (read/write) mode
FILE_SHARE_READ|FILE_SHARE_WRITE, // share mode
NULL, // security descriptor
OPEN_EXISTING, // how to create
FILE_FLAG_BACKUP_SEMANTICS, // file attributes
NULL // file with attributes to copy
);
FILE_NOTIFY_INFORMATION Buffer[1024];
DWORD BytesReturned;
while( ReadDirectoryChangesW(
hDir,
&Buffer,
sizeof(Buffer),
TRUE,
FILE_NOTIFY_CHANGE_SIZE, conditions
&BytesReturned, // bytes returned
NULL, // overlapped buffer
NULL// completion routine
))
{
if ( WaitForSingleObject(pView->m_StopEvent, 1) == WAIT_OBJECT_0 )
{
OutputDebugString(_T("\n KILL THE THREAD\n"));
return 0; //end the thread
}
CString fileName(Buffer[0].FileName);
fileName = fileName.Left(Buffer[0].FileNameLength / 2);
if(fileName.CompareNoCase(pView->m_LogFileName) == 0)
{
//Do the work
}
}
return 0;
}
Can anyone please help me to proceed further. I do not want to end the thraed from outside the function as it may cause memory leaks.
Thanks
Madhavi
|
|
|
|
|
The way I see is to put the wait function in the while condition with the or operator...
while( ReadDirectoryChangesW(
hDir,
&Buffer,
sizeof(Buffer),
TRUE,
FILE_NOTIFY_CHANGE_SIZE, conditions
&BytesReturned, // bytes returned
NULL, // overlapped buffer
NULL// completion routine
) || WaitForSingleObject(pView->m_StopEvent, 1) == WAIT_OBJECT_0)
{
OutputDebugString(_T("\n KILL THE THREAD\n"));
return 0; //end the thread
}
Unless it is not what you would like to do. The way I see your problem is that you want ReadDirectoryChangesW to check the directory and kill the thread if it see a change OR when the user click on the button.
|
|
|
|
|
I have traced the sample code (DDK src\storage\tools\spti)
This sample use the following procedure to write CDB to scsi device:
a. Use CreateFile function and specified path to obtain the handle of device.
b. Set each member of SCSI_PASS_THROUGH_WITH_BUFFER structure.
c. Use DeviceIoControl function and IOCTL_SCSI_PASS_THROUGH control code to write Cdb to device.
I have two questions :
1. How to map Cdb structure to Cdb array?
I want to use Cdb Structure like below:
cdb.START_STOP.OperationCode = SCSIOP_START_STOP_UNIT;
cdb.START_STOP.Immediate = 1;
cdb.START_STOP.Start = 0;
cdb.START_STOP.LoadEject = 0;
But the sample code uses Cdb array:
sptwb.spt.Cdb[0] = SCSIOP_MODE_SENSE;
sptwb.spt.Cdb[2] = MODE_SENSE_RETURN_ALL;
sptwb.spt.Cdb[4] = 192;
Is there any other way to write Cdb structure to device directly?
2. Can the Operation Code( SCSIOP_START_STOP_UNIT ) let hard disk spin down immediately?
Jesa
|
|
|
|
|
i have wiritten a activex control. I testted it using ActiveX test containser and in web application (in html). It works well.
But when include my activeX control in a dialog based application , mouse mouse events are not correctly posted to my activex control. Sometimes it posts sometimes it doesn't.
mouse down is also not posted. only when i clicked two times(not double click.one click after few seconds another click), one mouse down message is posted to my activex controls.
|
|
|
|
|
i want to get records from an SQL database, but i want the recoord to be displayed one by one. i know i should do it by surfing the records going to the next until End of File. But I also need to store the the data one by one in an array for use. Can someone please tell how to store each data in an array.
|
|
|
|
|
You can create a template(I'm not sure of the declaration syntax... so just search on msdn and you'll find...) array and then add the data in.
or
The better way I see is to create a struct and add one by one each elements to an array.
or
you can search msdn about recordset... if I remember well when you do a query in a database(for example : SELECT * FROM table) the query returns an array containing all element.
|
|
|
|
|
reenacutie wrote:
Can someone please tell how to store each data in an array.
If you are using MFC, check out the CArray class. The STL has a similar construct.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Can someone tell me if a modal property sheet can remain open while the control moves to the child.
I have an application where i have to display something on a new window .THe data comes from the modal property sheet but when I click on Close it clses the app .I tried using OnActivateChild but the program gave me a debug Assert failure.
Also if I have an existing modal dialog how do I change it to a modeless form??
Thanks
|
|
|
|
|
Hello all.
I cannot decide that HOW "to add text to a rectangle"
HELP ME !!!
|
|
|
|
|
What are you working on? Be more specific
<italic>Work hard, Work effectively and a bit of luck is the key to success.
|
|
|
|
|
Hello My name is Yun Hi Kim. I am a Korean. So I am sorry that my english is bad.
I am working UML application. I am using Visual C++6. It is my first application. So I cannot to do anything.
My UML application must to edit text in the shape such as ellipse and rectangle. Like as Visio(graphics diagram). How to do this.
|
|
|
|
|
|
NEED MORE INFORMANCE
Vengeance is savage kind of justice
|
|
|
|
|
Hello My name is Yun Hi Kim. I am a Korean. So I am sorry that my english is bad.
I am working UML application. I am using Visual C++6. It is my first application. So I cannot to do anything.
My UML application must to edit text in the shape such as ellipse and rectangle. Like as Visio(graphics diagram). How to do this.
|
|
|
|
|
|
I need to write a Windows VC++ 6.0 Web service client that requires to
Allow user to browse all WebService Methods and arguments dynamically w/o WSDL using MFC/SDK/ATL.(NO .NET)
Allow user to call the methods.
How to write that?
I am new to C++. You are welcome to give samples or links.
Thanks in advance
|
|
|
|
|
Hello Friends,
I the following code given below
#include <iostream.h>
void fun()
{
cout <<"in function one " << endl;
}
int main()
{
fun();
return 0;
}
The above program is complied and the output is shown
"in function one".One thing please notice that the function prototyping is not done here.
In the second the cpp program
#include <iostream.h>
int main()
{
fun();
return 0;
}
void fun()
{
cout <<"in function one " << endl;
}
In the second cpp program the function "fun()" is defined after the main().
This cpp shows an error which is given below.
//////////////////////////////////////////////////////////////////////////////
mpiling...
fun2.cpp
d:\c++\fun2\fun2.cpp(6) : error C2065: 'fun' : undeclared identifier
d:\c++\fun2\fun2.cpp(11) : error C2373: 'fun' : redefinition; different type modifiers
Error executing cl.exe.
fun2.exe - 2 error(s), 0 warning(s)
//////////////////////////////////////////////////////////////////////////////
In the first the cpp program the , the function declaration and the body is done before the main .In the cpp program the function declaration ie function prototying is not done here.
In the scecond cpp program, the funtion is defined, after the main function. the cpp program shows the error which is given above.If the function prototying the funtion is given ie. declaration function before the main , the above error can be avioded.
Can any one tell me what is the difference between the two programs.
Hoping for a reply.
Yours,
Phijo
|
|
|
|
|
You've pretty clearly said what the difference is. C++ requires the prototype of the function before it is used. In the first case, you've defined the function itself before its use, so it compiled fine. In the next case, the compiler was not able to see the prototype for fun() when it was used in main(), so it complained.
In C, you can get away without declaring a function if the function takes no parameter and returns an int. The C compiler assumes that prototype if it doesn't see one. That is not legal in C++ though.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
your first sample program.....
#include
void fun()
{
cout <<"in function one " << endl;
}
int main()
{
fun();
return 0;
}
workz fine coz the compiler lookz for all the function that are defined above it!!!!!
your second program......
#include
int main()
{
fun();
return 0;
}
void fun()
{
cout <<"in function one " << endl;
}
doesnt work coz as said the compiler lookz for all the function definitionz that are defined above the main function.....
if u have to get thiz above code working.....u have to give the compiler the indication that there is a function defined by giving a formal definition function prototype.....
coz once it reaches the void main it executes the code and findz ur function that is defined(with no prototype) as an undeclared type!!!!!.....
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
I have this app that opens a bitmap image and displays it in the dialog. However, when I move it off screen then back on, the portion that was offscreen but is now on screen is not refreshed. I think I have to handle some kind of message like WM_PAINT somewhere but I don't know quite where to do this exactly. I'm thinking of overriding CCmdTarget::OnCmdMsg and doing it in there somehow. Rather than making an uninformed guess at the best way at doing this and wasting time writing code I don't need, I'd like to ask up front as to what's the best way to do this. I'd like to redraw when the window is placed in it's final location (after left mouse button is released) but I would like to redraw it more intelligently after I get this part figured out. Any help would be greatly appreciated and thanks to all the people that have helped me in the past with this app.
|
|
|
|
|
You should do all your drawing in your WM_PAINT handler. Your window will recieve WM_PAINT messages from the system whenever it needs redrawing, for whatever reason.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|