|
shakumar_22 wrote: Some of them said read file in Binary format, but i dont know how to read in binary format.
See here for the difference between binary and text files. That said, consult MSDN for the distinction between CFile and CStdioFile .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I have successfully created a winform user control that i use on a webform by exposing it as an ActiveX control using the <object> tags.
Is there a way for me to access the objects public methods/properties from the ASP.NET code behind files when i post the aspx page back to the server?
Sinoop Sundar, Colossal Technologies
|
|
|
|
|
Hello Friends,
Does anybody know a function to monitor the single file and not the folder. I know there is a function named FindFirstChangeNotification() but that monitores the Folder or Folder tree I want to Monitor the Single File :->. Becoz When I am using the above function I am facing lots of probelms that i have posted earlier. (see Just below post)
|
|
|
|
|
hi,
you can take a look to the native API function ZwQueryDirectoryFile that are capable to help you in your research.
|
|
|
|
|
Hello Friends,
I have a little problem.I m working on a project.In this project we have a tree view wich shows the files. When user clicks on the file a new process created ( Say Notepad, It may be any Software, MSWord Too) and a File user has clicked opened in it. I have to moniter the that file.(i.e. When user save the changes he has made has to upload the file somewhere) for that I have created the thread when the process is created and in the Thread Procedure I am Monitoring the file using FindFirstChangeNotification() function. It works fine when the user has created a single process(i.e. Has open the single file) . But the problem occures when user has created more than on file. Becoz each time user creates the file a thread is created and it does the same thing (i.e. Monitor the perticular directory, in my case it is Temp)which another thread from earlier process is doing. So all the things is happening as many times the user has opened the process.
For Example. I am displayig the MessageBox when user save the file. if user has created 3 process and even if it saves the single file 3 MessageBox displyes to him.(and all the other task is also happend many times rather than one)
Below are some of the code that i am using.
<br />
if (CreateProcess(0, str, 0, 0, 0, 0, 0, 0, &startupinfo, &ProcessInformation))<br />
{<br />
DWORD lpExitCode; <br />
HANDLE hMonitorThread=CreateThread(0,0,(LPTHREAD_START_ROUTINE)MyThreadProc,NULL,0,0);<br />
GetExitCodeThread(hMonitorThread,&lpExitCode);<br />
HANDLE handles[2];<br />
handles[0] = (HANDLE)pQueueData->retrycount;<br />
handles[1] = ProcessInformation.hProcess;
int res=WaitForMultipleObjects(2, handles, FALSE, INFINITE);<br />
if (res==(WAIT_OBJECT_0+1) || res==(WAIT_ABANDONED_0+1))<br />
{<br />
if(TerminateThread(hMonitorThread,lpExitCode))
<br />
CloseHandle(ProcessInformation.hProcess);<br />
Sleep(500);<br />
...<br />
...<br />
}<br />
void MyThreadProc(void)<br />
{<br />
while(TRUE)<br />
{<br />
<br />
hFile = FindFirstChangeNotification(szTempDir,TRUE,FILE_NOTIFY_CHANGE_SIZE);<br />
dwWaitOver = WaitForSingleObject(hFile,INFINITE);<br />
if(!dwWaitOver)<br />
{<br />
if(::MessageBox(NULL,"You Have just Saved the File \n Want to make Changes on the Server", "MainFrame",MB_YESNO|MB_SYSTEMMODAL|MB_ICONINFORMATION ) == IDYES)<br />
{<br />
AfxGetApp()->m_pMainWnd->PostMessage(WM_APP, reinterpret_cast<WPARAM>(MypQueueData),(LPARAM)DoNotDelete)<br />
<br />
}<br />
}<br />
FindNextChangeNotification(hFile);<br />
<br />
}<br />
<br />
Now i dont know what to do. Is there any function that monitores the perticular file change rather than a folder. or is there any way I can improve the codeing and solve the problem. I have tried to Create a single thread to monitor for all process but it has its own problem
So if U have any solution please tell me..
|
|
|
|
|
may be you can try the ReadDirectoryChangesW() function. cause if you use that function, you can find which file actually changed. so if it is not the file you needed, you can ignore it and continue watching..
|
|
|
|
|
I have tryed to use the function you have told me to. But i failed to use this. might be becoz i am novice programmer in VC++.
I dont know what error come but I fail to retrive the File name.
void ReadFileChange(void)<br />
{ <br />
OutputDebugString(" ReadFileChange() ");<br />
char* path = "C:\\DOCUME~1\\gaurang\\LOCALS~1\\Temp";<br />
BOOL Success;<br />
DWORD dwByteReturned;<br />
FILE_NOTIFY_INFORMATION Buffer;<br />
<br />
int size = sizeof(FILE_NOTIFY_INFORMATION);<br />
<br />
HANDLE hDir = CreateFile(path,FILE_LIST_DIRECTORY,<br />
FILE_SHARE_READ|FILE_SHARE_DELETE, <br />
NULL,OPEN_EXISTING, <br />
FILE_FLAG_BACKUP_SEMANTICS,NULL<br />
); <br />
<br />
Success = ReadDirectoryChangesW(hDir,&Buffer,64,FALSE,FILE_NOTIFY_CHANGE_SIZE,<br />
&dwByteReturned,NULL,NULL);<br />
if(!Success)<br />
OutputDebugString("Read Directory Change Failed ") ; <br />
OutputDebugStringW(Buffer.FileName);<br />
<br />
}
I dont know what to use in as the size in Buffersize parameter. so I just took 64.
|
|
|
|
|
Gaurang Shah 033 wrote: I dont know what to use in as the size in Buffersize parameter. so I just took 64.
some pblms in the code. i have corrected it. Check it. the pBuffer->FileName will be having the file name.
char* path = "C:\\DOCUME~1\\gaurang\\LOCALS~1\\Temp";<br />
BOOL Success;<br />
DWORD dwByteReturned;<br />
int size = sizeof(FILE_NOTIFY_INFORMATION) + (MAX_PATH * 2);<br />
FILE_NOTIFY_INFORMATION* pBuffer = (FILE_NOTIFY_INFORMATION*) new BYTE[ size ] ;<br />
HANDLE hDir =CreateFile ( path,<br />
GENERIC_READ,<br />
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,<br />
NULL,<br />
OPEN_EXISTING,<br />
FILE_FLAG_BACKUP_SEMANTICS,<br />
NULL<br />
);<br />
Success = ReadDirectoryChangesW( hDir,pBuffer,size,FALSE,FILE_NOTIFY_CHANGE_FILE_NAME, &dwByteReturned,NULL,NULL);<br />
delete pBuffer;
|
|
|
|
|
Hello,
If I want to write an equality operator for a menu class derived from CMenu than can I write as follows
class Menu : public CMenu
{
Menu& operator= (Menu& M) ;
};
Menu& Menu::operator= (Menu& M)
{
this->m_hMenu = M.m_hMenu;
return *this;
}
Will this equate one Menu = Another Menu ?
Are there any hidden problems?
Thanks
Prithaa
|
|
|
|
|
prithaa wrote: Menu& Menu::operator= (Menu& M)
you have overloaded assignment operator, not == operator. So you will be able assign one menu to another menu.But cannot compare. Also there is a potential problem. Suppose you wrote like.
Menu A;
{
Menu B;
B.create(..)
A = B;
}// Menu b goes out of scope and the menu inside it will get detroyed. So what Menu A will be having is an invalid handle.
|
|
|
|
|
Have you considered just using the IsKindOf() method?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I am developing application which has to use third party dll,(for scanning)who only has described exported functions with function definition.
After I developed a application,which gives proper result but it gives assertion in debug mode at each and every call of function imported from dll. Following is assertion.
"The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention."
And after completion of process (scanning) application terminates.
I read articles from google,msdn and included __stdcall ,WINAPI ,combination
but error comes as it is. In release mode assertion does not come.but application crashes everytime. I cannot debug it as application is terminating after passing end of function call. Only all it shows in debug is access violation and all binary code.
|| ART OF LIVING ||
|
|
|
|
|
Hi
I have a dll application, which was compiling/linking fine and working correctly. I have to add a function to say class B.cpp/B.h which is similar to another function in another class say A.cpp/A.h. So I copied the function from A and made changes and added it to B. When i compiled it, there was a undeclared identifier error on a function. I checked where the function was defined and added
#include xyz.h on the top of the B.cpp.
When i compiled it now, it gave me lots of LNK2005 error with message "already defined in B.obj". I worked mostly in C#, so have on idea of this linking issue. Most of the google searches ask me to change project settings, which is not solving the problem.
Regards
Shajeel
|
|
|
|
|
Its very simple.
Project - > settings
Go to linker tab.
In linker tab project options edit box at end , just add
-------> /FORCE:MULTIPLE
Press ok.
I hope your problem will be solved.
|| ART OF LIVING ||
|
|
|
|
|
I am using VS 2002, can you tell me settings for that as i don't have any Project -> settings options here.
Regards
Shajeel
|
|
|
|
|
I am sorry I am using vc 6.0 only.
|| ART OF LIVING ||
|
|
|
|
|
Hello,
I have a question in the same regard. Just now I tried what you suggested /FORCE:MULTIPLE since I was getting Linker error saying 'already defined'.
Now because the settings are changed I get warnings saying that the 'x identifier already defined in MainFrm.obj; second definition ignored'
So should I stick on to these new settings because even I tried all of the following for my identifier consts file
#pragma once
#ifndef
#define
#endif
But none of the above worked.With your suggestion the errors are transferred to warnings.
What exactly this /FORCE:MULTIPLE do?
Thanks
Prithaa
|
|
|
|
|
Force multiple just ignores second definition with same name.
It is generally risky for very big projects in VC++. But I never found it that risky.
|| ART OF LIVING ||
|
|
|
|
|
Hello,
Thanks,
For now my problem is solved.I'll keep this in mind.
Bye
Prithaa
|
|
|
|
|
prithaa wrote: What exactly this /FORCE:MULTIPLE do?
See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
/FORCE:MULTIPLE?
Just adding a function to another class shouldn't give new linker errors,
unless you never define the function.
Did you copy the function and not change the scope resolution stuff?
With namespaces and classes (C++!) there shouldn't ever be multiple
definitions.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
Because of this FORCE:MULTIPLE my linker errors "already defined in another class' have become warnings so is that fine?
I had tried using
#pragma once
#ifndef
#define
#endif
but none of them worked
Thanks
Prithaa
|
|
|
|
|
I'm just suspicious -
What is defined twice in two different classes ? Is this really what you want?
Hiding it with a linker option may not be the best solution
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am trying to expose bitmap from active x control.
I am trying to expose BYTE pointer from active x control.
Can anyone give some suggestions
S.Yamini
|
|
|
|
|
How can data be transferred into excel sheet 'row and column-wise' the way we do in list control?? My first row consists of fixed column names
|
|
|
|