|
i use the SHBrowseForFolder() API to prompt the user to select a folder.
but i can't open the dialog in a particuliar folder. how to do that please ?
-- TTD --
|
|
|
|
|
The pidlRoot parameter of the BROWSEINFO structure is used for that.
Do a search for that member and you will find ways to manage the ITEMIDLIST required for the structure.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
yes, i know that james, sorry for not having pointed out my tries.
actually, i called CoInitialise(NULL) first, and i tried to use SHParseDisplayName() to create a PCIDLIST_ABSOLUTE to give to the pidlRoot attribute of the structure, in vain
-- TTD --
|
|
|
|
|
super_ttd wrote: but i can't open the dialog in a particuliar folder. how to do that please ?
Have you supplied a callback function? That is where you establish the default folder.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Have you supplied a callback function?
hu, no ! i thought callbacks were only to extend the dialog style/events management...
Sir, can i ask you please to show me how you write such a function ?
thank you very much for your answer
|
|
|
|
|
super_ttd wrote:
hu, no ! i thought callbacks were only to extend the dialog style/events management...
You can use it for whatever you need.
super_ttd wrote: Sir, can i ask you please to show me how you write such a function ?
I could, but Googling for examples would prove a much more useful exercise.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Symphton
When I delete directory which contains some files I will not get message FILE_ACTION_REMOVED. This happens int XP professional SP1. I can't install SP2 because some others reasons.
My code
initialization of watching
DirInfo[0].hDir = CreateFile(sDirectory,
FILE_LIST_DIRECTORY,
FILE_SHARE_READ |
FILE_SHARE_WRITE |
FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS |
FILE_FLAG_OVERLAPPED,
NULL
);
if(DirInfo[0].hDir==INVALID_HANDLE_VALUE)
return IDS_ERRCREATEFILE;
hCompPort=0;
hCompPort=CreateIoCompletionPort( DirInfo[0].hDir,
hCompPort,
(DWORD) &DirInfo[0],
0);
if(!hCompPort)
return IDS_ERRCREATEIOPORT;
ReadDirectoryChangesW( DirInfo[0].hDir,
DirInfo[0].lpBuffer,
MAX_BUFFER,
TRUE,
FILE_NOTIFY_CHANGE_SECURITY|
FILE_NOTIFY_CHANGE_CREATION|
FILE_NOTIFY_CHANGE_LAST_ACCESS|
FILE_NOTIFY_CHANGE_LAST_WRITE|
FILE_NOTIFY_CHANGE_SIZE|
FILE_NOTIFY_CHANGE_ATTRIBUTES|
FILE_NOTIFY_CHANGE_DIR_NAME|
FILE_NOTIFY_CHANGE_FILE_NAME,
&DirInfo[0].dwBufLength,&DirInfo[0].Overlapped,
NULL);
watching loop in other thread
unsigned __stdcall CFileChangeWatch::DoFileChangeWatch(void *_pcFileChangeWatch)
{
DWORD numBytes;
DWORD cbOffset;
LPDIRECTORY_INFO di;
LPOVERLAPPED lpOverlapped;
PFILE_NOTIFY_INFORMATION fni;
CString szFullFileName;
CFileChangeWatch *pcFileChangeWatch=(CFileChangeWatch *)_pcFileChangeWatch;
char sBuff[256];
CString sPath;
do
{
GetQueuedCompletionStatus( (HANDLE) pcFileChangeWatch->hCompPort,
&numBytes,
(LPDWORD) &di,
&lpOverlapped,
INFINITE);
if ( di )
{
fni = (PFILE_NOTIFY_INFORMATION)di->lpBuffer;
do
{
cbOffset = fni->NextEntryOffset;
szFullFileName=di->lpszDirName;
szFullFileName=szFullFileName + "\\";
szFullFileName=szFullFileName+ CString(fni->FileName).Left(fni->FileNameLength / 2);
if(!strcmp(szFullFileName.Right(3),"fdf"))
{
DBAction
switch(fni->Action)
{
case FILE_ACTION_ADDED:
break;
case FILE_ACTION_REMOVED:
break;
case FILE_ACTION_MODIFIED:
break;
case FILE_ACTION_RENAMED_OLD_NAME:
break;
case FILE_ACTION_RENAMED_NEW_NAME:
break;
default:;
}
fni = (PFILE_NOTIFY_INFORMATION)((LPBYTE) fni + cbOffset);
} while( cbOffset );
ReadDirectoryChangesW( di->hDir,di->lpBuffer,
MAX_BUFFER,
TRUE,
FILE_NOTIFY_CHANGE_SECURITY|
FILE_NOTIFY_CHANGE_CREATION|
FILE_NOTIFY_CHANGE_LAST_ACCESS|
FILE_NOTIFY_CHANGE_LAST_WRITE|
FILE_NOTIFY_CHANGE_SIZE|
FILE_NOTIFY_CHANGE_ATTRIBUTES|
FILE_NOTIFY_CHANGE_DIR_NAME|
FILE_NOTIFY_CHANGE_FILE_NAME,
&di->dwBufLength,
&di->Overlapped,
NULL);
}
} while( di );
return 0;
};
-- modified at 9:28 Tuesday 21st November, 2006
|
|
|
|
|
Have you tried the sample application from CDirectoryChangeWatcher[^]. Still nothing? Do you have the same problem? Then you really need to update to SP2. Sorry, but good luck!
|
|
|
|
|
I tried this demo, but on the machine, where my code doesn't work this demo doesn't work either. it really sucks.
|
|
|
|
|
You should read this[^] first.
Do take a look at point 4 and 5.
|
|
|
|
|
|
as required by the administrator here[^] (see 5.), please edit your message (not posting a new one) and post the code samples inside <pre>...</pre> html tags...
thank you
|
|
|
|
|
In my program iam using a named pipe for reading from source to destination programs. but when the source is waiting for input from destination(via another pipe) i cant read from the pipe .Only after the input was given ,the reading is possible.
Can I use any other technique by replacing pipes.
(Source and destination programs are at same machine)
vineesh
|
|
|
|
|
you can use select system call or do non-blocking IO using fcntl system call.
--
Pratap
|
|
|
|
|
you can check whther there is data present on the pipe or not
bu calling PeekNamedPipe() api so that you can come to know data is
available or not!!
and then make ReadFile() call is data is available
i did not understood your problem very well but this can be your solution
so replied
bye
Harshal
|
|
|
|
|
How can i hide columns ??????!!!!!
I have CDialog base aplication and... a CListCtrl m_list1.
I have 7 columns ,(0,1,2,3,4,5,6,7) and i want to hide 3 of them when i whant !!!!! HOW ???????
it is posibile ????
Bravoone
|
|
|
|
|
|
As a simple trick you can assign size 0 to the intended columns,
using SetColumnWidth( nCol, 0 )
It works, but the user can enlarge the columns if he wants...
|
|
|
|
|
Bravoone_2006 wrote: I have 7 columns ,(0,1,2,3,4,5,6,7)
excuse me, but from 0 to 7 , it gives you 8 ones !!!
|
|
|
|
|
Hi,
In a current tool, that copies Sources from a server, zips them and sends the zip-File to another server, I have to delete the intermediate zip-Files stored locally about after a week (so that they still are available if the recipient claims a transfer failure).
I can't use CTime procedures for determining that week as the tool itself was created as Win32 console application without MFC support, so I tried to get the Local Time with GetLocalTime(&now), convert this to a FILETIME and compare it with the FILETIME got from the creation date of the file to decide wether this file is to be kept or deleted. According to the help pages FILETIME holds intervals of 100 nanosecond, so a week would calculate to 7(days)*24(hours)*60(minutes)*60(seconds)*1000(milliseconds)*1000(microseconds)*10(intervals of 100 nanoseconds) = 6048000000000 intervals.
The help pages tell me that I have to copy the FILETIME to a LARGE_INTEGER before I can compare the dates so I tried the following code:
LARGE_INTEGER liNow,liFile;
liNow.LowPart = ftNow.dwLowDateTime;
liNow.HighPart = ftNow.dwHighDateTime;
liFile.LowPart = localDateCreated.dwLowDateTime;
liFile.HighPart = localDateCreated.dwHighDateTime;
if(liNow.QuadPart - liFile.QuadPart > 6048000000000)
{ ... }
Now I have the problem that none of my files reach the deletion part of the code, even files two weeks old only have a difference of 1604372500. Is something wrong with my calculation, my conversion to LARGE_INTEGER or is the whole approach faulty?
Hope anyone can help me
Martin Dietz
|
|
|
|
|
How do you obtain the creation time of the file?
|
|
|
|
|
When I use FindFirstFile, and FindNextFile in the loop afterwards, I get a lot of data stored in a WIN32_FIND_DATA structure, among others creationtime, lastAccessTime and LastWriteTime.
Hmm... Maybe I used the wrong member and should try ftLastWriteTime, as this doesn't change when copying. I'll try that approach and call back later (or tomorrow)
|
|
|
|
|
m.dietz wrote: When I use FindFirstFile, and FindNextFile in the loop afterwards...
Are you then calling FileTimeToLocalFileTime() ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Yes, as I'm calling GetLocalTime the File time has to be converted to Local Time too. It seems I just looked at the wrong filetime member of WIN32_FIND_DATA struct; after looking at ftLastWriteTime instead of ftCreationTime the files older than a week were correctly identified.
|
|
|
|
|