I would like to give it a try
g3e
Posts
-
Need a few more testers to try C++ XML Library. -
Please help on this problemLooks like you are trying out the ADO tutorial in MSDN. The variables adVarChar etc.. are in msado15.dll. Did you import the "c:\Program Files\Common Files\System\ADO\msado15.dll" into your program?
-
Help needed!!! FileSystemWatcherHi mav.. Thanks for your reply. When i tried to debug the program when i first faced this problem I found that the FileSystemWatcher was only holding the file:confused: So when i tried google it, many others had also said the same. That is why the wait logic was introduced. Yes i can do away with the recursion logic. Regards, G3
-
Help needed!!! FileSystemWatcherHi, I've written a windows service to parse files.It uses the FileSystemWatcher class in C# to sniff a folder for particular type of files. But when the files were being processed, i repeatedly get the error "The process cannot access the file "AAA" because it is being used by another process". To overcome this problem, i added the following. lines of code
public bool ParseEnvFile(string strFilePath)
{
try
{
using(FileStream fs = new FileStream(strFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
// Do some processing here
fs.Close();
m_nReadAttempts = 0;
}
}
catch(IOException ex)
{
if(m_nReadAttempts < 3)
{
Thread.Sleep(2000);
m_nReadAttempts++;
return ParseEnvFile(strFilePath);
}
else
{
throw ex;
}
}
.....
}But even this did not solve the problem. The exception still kept coming, though less frequently. So I was forced to add a Timer event(runs every 5 mins) that would pick up all the files that were left over because of the exception. Now, my problem is this: When a file gets created in the folder, sometimes both the OnFileCreated event and the timer event try to access the file at the same time. Within my service, I'm required to open the file in write mode and update some contents. I find that at times the file that gets created ends up as a 0KB file (Note: when it initially got created the file had some content in it)!!!! Any ideas on how to solve it? Thanks for any help in resolving this problem.
-
FileSystemWatcher - File used by another processHi, I've written a windows service to parse files.It uses the FileSystemWatcher class in C# to sniff a folder for particular type of files. But when the files were being processed, i repeatedly get the error "The process cannot access the file "AAA" because it is being used by another process". To overcome this problem, i added the following. lines of code
public bool ParseEnvFile(string strFilePath) { try { using(FileStream fs = new FileStream(strFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { // Do some processing here fs.Close(); m_nReadAttempts = 0; } } catch(IOException ex) { if(m_nReadAttempts < 3) { Thread.Sleep(2000); m_nReadAttempts++; return ParseEnvFile(strFilePath); } else { throw ex; } } ..... }
But even this did not solve the problem. The exception still kept coming, though less frequently. So I was forced to add a Timer event(runs every 5 mins) that would pick up all the files that were left over because of the exception. Now, my problem is this: When a file gets created in the folder, sometimes both the OnFileCreated event and the timer event try to access the file at the same time. Within my service, I'm required to open the file in write mode and update some contents. I find that at times the file that gets created ends up as a 0KB file (Note: when it initially got created the file had some content in it)!!!! Any ideas on why this happens? Thanks for any help in resolving this problem. -
Arghh! Visual C++ deletes project files!I use VC5 on XP machine and have faced the problem of the cpp file getting deleted. I had to rewrite the whole thing.:doh:
-
I'm puzzledI've implemented a wizard using the CPropertySheet and CPropertyPage classes. When i'm in a particular page of the wizard, when i click the "Cancel" button or press ESC or close the page by clicking on the "X" in the right top corner, the CANCEL message gets fired and control comes to the OnCancel command handler. At this point the PSN_WIZFINISH notification is not sent. void CMyPropertyPage::OnCancel() { ASSERT(m_pSheet != NULL); m_pSheet->EndDialog(IDCANCEL); } Now I have a scenario where i have to forcefully close the wizard by sending SendMessage(WM_COMMAND,IDCANCEL); Now after the CANCEL message being sent, the PSN_WIZFINISH notification is also sent . :confused: In my class, i've overridden the OnWizardFinish to do some functionality.. So when i do a "SendMessage" i dont want the PSN_WIZFINISH to be sent .. why does it work this way and how do i avoid it ?
-
Problem in Wizard - OnCancel / OnWizardFinishI've implemented a wizard using the CPropertySheet and CPropertyPage classes. When i'm in a particular page of the wizard, when i click the "Cancel" button or press ESC or close the page by clicking on the "X" in the right top corner, the CANCEL message gets fired and control comes to the OnCancel command handler. At this point the PSN_WIZFINISH notification is not sent. void CMyPropertyPage::OnCancel() { ASSERT(m_pSheet != NULL); m_pSheet->EndDialog(IDCANCEL); } Now I have a scenario where i have to forcefully close the wizard by sending SendMessage(WM_COMMAND,IDCANCEL); Now after the CANCEL message being sent, the PSN_WIZFINISH notification is also sent :confused: In my class, i've overridden the OnWizardFinish to do some functionality.. So when i do a "SendMessage" i dont want the PSN_WIZFINISH to be sent .. why does it work this way and how do i avoid it ? Thanx for ur help.
-
How to check if logged on user has admin privilegesHow to check if the logged on user has admin privileges on the system ? Is there any API to do that ?? The API should be supported on all windows platforms ( Win NT, XP, 2000, Win 98/95/ME). Thanks for ur help.
-
Crash in ocx CreateFollowing are my sequence of steps for creating ocx. if(!ocx.Create(...)) { Register the Ocx if(!ocx.Create(...)) throw error message } The first create fails. the control comes inside the if . Registration of ocx succeeds. But on the second create, the application crashes !!?? Can anyone tell me why ??
-
very simple but i don't know CheckBox(CButton*)GetDlgItem(IDC_XXX))->SetCheck(TRUE)
-
CPropertySheetThanx for all ur responses. Its working now !!! I tried first to post a user defined message from the sheet's InitDialog. But that did not work as expected. Then i tried the same from the InitDialog of the property page. And it worked just as required. Thanx again.
-
CPropertySheetI have a wizard derived from propertysheet. It is a modal dialog which is invoked using DoModal(). Immediately after the wizard is displayed, I want to popup a dialog. But i'm not able to track the exact point after the wizard is shown. In which method of the wizard can i do this ??? Thanx for ur help.
-
how to change printers without PrintDialog?1 : Get the handle to devmode and devnames structures by calling the OpenPrinter and GetPrinter API calls and populate PRINTER_INFO_2 strucure. Copy these handles to printInfo.m_pPD->m_pd.hDevMode and printInfo.m_pPD->m_pd.hDevNames 2 : Call SelectPrinter() API with the handles. Make sure to reset to the original printer properties.
-
How to get process id given the process nameThanks a lot. That works.
-
How to get process id given the process nameHi, From within my application i need to wait for an external process to complete before proceeding. But all i have is the external process's name. Is there any API that returns the process id or handle given the process name ?? I tried using CreateToolhelp32Snapshot but it does not seem to work in VC41 in which my application is built. It works fine in VC6 though. Thanks for ur help.