|
That works fine only. I am talking about "dwType"
Sethuraman.K
|
|
|
|
|
The value of ERROR_SUCCESS is 0.
So, in you code if it is entering if(Result) , it means you are not getting ERROR_SUCCESS , which means an error in the open itself.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I got the solution. If our application is 32bit then registry entry (only for HKEY_LOCAL_MACHINE) in 64 bit OS sould be in
HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node
in my case entry should be in
HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Test\\App
Sethuraman.K
|
|
|
|
|
Hi All
I am useing timer in main dialog class.Calling Timer on On OnInitDialog function.But my dilaog become not responding.Plz help me.
|
|
|
|
|
It is most likely because you did something wrong.
...
but seriously, give some code, more details, otherwise noone will be able to help you.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
How are you 'Calling Timer' (you know, no code => no help... )?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
void CTimer::OnTimer(UINT_PTR nIDEvent)
{
OnBnClickeTimer();
CDialog::OnTimer(nIDEvent);
}
void CTimer::OnStartTimer()
{
SetTimer(2,10000, 0);
}
void CTimer::OnStopTimer()
{
KillTimer (0);
}
BOOL CTimer::OnInitDialog()
{
OnBnClickeTimer();
}
void CTimer::OnBnClickedTimer()
{
check:
for(;aq<10)
{
finalString=a1[aq];
char * szMyString = (char *)(LPCTSTR)finalString;
CString string = _T(szMyString);
CString DirPath;
CString string1=string;
string1 +='\0';
int nLen = string1.GetLength();
LPCSTR lpszBuf = string1.GetBuffer(nLen);
string1.ReleaseBuffer();
LPCSTR pF=lpszBuf;
LPCSTR pT="c:\\Backup";
if (!fo.Copy(pF,pT));
aq++;
}
OnStopTimer();
}
CString a1[aq] is external vaiable.
Plz help me
modified on Tuesday, February 24, 2009 6:43 AM
|
|
|
|
|
- Please check the posted code (for instance use
< to escape the symbol < when required). - Why are you calling directly the timer function inside
OnInitDialog (instead of starting the timer? You may actually do it, but usually you haven't...)? - Since you're calling directly (form
OnInitDialog ) your timer function (OnBnClickedTimer ) it doesn't make sense the OnStopTimer call in the latter.
Anyway your application 'freezes' possibly because of a bug in your loop. You should debug it in order to have a clue about (ispecting your code is also difficult because of the, already mentioned, bad formatting).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Also i think he is not passing correct id to KillTimer..
Regards,
Sandip.
|
|
|
|
|
Yes, you are right, of course.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Timers tutorial[^] is for you.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I want to open all files with a certain name and/or a certain type, but for that I need to know the contents of a directory first.
How do I see them?
Thanks.
|
|
|
|
|
FindFirstFile and FindNextFile should do it.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
|
Thanks.
I got something (I think) with FindFirstFile and FindNextFile .
Though, it doesn't quite work, this whole code is in a try catch block, but still throws a System.AccessViolationException (which is .NET specific and I can't use it or acces it) and does nothing:
try
{
fstream file;
vector<lpwin32_find_dataw> files;
LPCTSTR namepointer;
HANDLE handle;
string line = "";
int i = 0;
int size;
char directory [] = "C:\\Folder";
char *stringpointer = directory ;
files.assign(1, LPWIN32_FIND_DATAW());
handle = FindFirstFile(namepointer, files[i]);
while (handle != INVALID_HANDLE_VALUE)
{
FindNextFile(handle, files[i]);
files.assign(1, LPWIN32_FIND_DATAW());
i++;
}
size = files.size();
cout << files.size() << endl;
for (int k = 0; k < size; k++)
{
cout << "Reading File:" << files[k]->cFileName << endl;
}
getchar();
return 0;
}
catch (exception ex)
{
cout << "An error has occurred." << endl;
cout << ex.what() << endl;
}</lpwin32_find_dataw> I want to read the filenames to check if they're txt files with the right kind of name and then read from them to process the text of each.
Thanks.
|
|
|
|
|
Megidolaon wrote: ...but still throws a System.AccessViolationException...
Where/when?
Why do you have a vector of WIN32_FIND_DATA structures? One is sufficient.
Megidolaon wrote: handle = FindFirstFile(namepointer, files[i]);
What is the value of namepointer ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
It throws the exception right at the start and does nothing else.
DavidCrow wrote: Why do you have a vector of WIN32_FIND_DATA structures? One is sufficient.
FindFirstFile and FindNextFile seemed to return only as single file, so I assumed LPWIN32_FIND_DATAW represented a single file.
How does that work anyway?
The struct only has a few attributes that seem like file attributes, which wouldn't make much sense in a collection (like filename or creation date).
Originally I had
namepointer = stringpointer; but that won't do.
I get an error that char* cannot be converted to LPCTSTR.
I must have deleted the line and didn't notice.
Though, it was done like that in the article Hamid posted (then again, I got 10 errors from that code).
|
|
|
|
|
Megidolaon wrote: FindFirstFile and FindNextFile seemed to return only as single file, so I assumed LPWIN32_FIND_DATAW represented a single file.
It does, hence the need for a loop.
Look through this snippet to see where you went awry:
vector<string> files;
WIN32_FIND_DATA findData;
BOOL bFound = TRUE;
HANDLE handle = FindFirstFile("C:\\*.*", &findData);
if (handle != INVALID_HANDLE_VALUE)
{
while (bFound)
{
files.push_back(findData.cFileName);
bFound = FindNextFile(handle, &findData);
}
}
for (int k = 0; k < files.size(); k++)
cout << "Reading File:" << files[k].c_str() << endl;
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks, though this code stil throws 2 errors.
First one that I can't convert from const char[7] to LPCWSTR (in FindFirstFile ).
Second one is that I can't convert from WCHR[260] to std::string & (files.push_back(findData.cFileName); ).
|
|
|
|
|
Megidolaon wrote: Thanks, though this code stil throws 2 errors.
That's because you are using Unicode. Change string to wstring and prepend the string literal with an L .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I see now it compiles.
But the program doesn't quite work.
It doesn't display anything and when setting a breakpoint it takes over a minute until it reaches it (first call of FindFirstFile )
After that line I get an error, saying that there is no cource code available for the current position.
I don't get any error or output if I don't use a breakpoint.
|
|
|
|
|
Megidolaon wrote: It doesn't display anything...
Does the files vector contain anything?
What does your code look like?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
vector<wstring> files;
WIN32_FIND_DATA findData;
BOOL bFound = TRUE;
HANDLE handle = FindFirstFile(L"C:\Dokumente und Einstellungen\Student\Eigene Dateien", &findData);
if (handle != INVALID_HANDLE_VALUE)
{
while (bFound)
{
files.push_back(findData.cFileName);
bFound = FindNextFile(handle, &findData);
}
}
for (int k = 0; k < files.size(); k++)
{
cout << "Reading File:" << files[k].c_str() << endl;
}
getchar();</wstring> I copied your code and used wstring, then added an L to the filepath, as you said.
I used getchar() , to keep the console open.
I made a break point at the line of files.push_back(findData.cFileName);, but the program never reaches that line.
It simply does nothing, probably because when I put a breakpoint at the FindFirstFile line and then go the next line with F11, I get an error telling me that for the current position no source code is avaiable.
modified on Monday, March 2, 2009 5:23 AM
|
|
|
|
|
Megidolaon wrote: HANDLE handle = FindFirstFile(L"C:\Dokumente und Einstellungen\Student\Eigene Dateien", &findData);
You need to use double backslashes.
What is the value of handle ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I have double backslashes, codeproject didn't display the code properly.
I tried it with this conde and with using \\*.* at the ne dof the filepath, but it's the same.
I get that error in both cases.
|
|
|
|