|
Well even on multiple cores, there's no way for user code to predict thread scheduling sequence.
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]
|
|
|
|
|
includeh10 wrote: I hope that I can see 2 treads call the function in turn.
Hope away. In software development, there is no room for hope.
FWIW: the macroscopic behavior of threads (at a rate the human eye can discern) often is quite different from their actual, microscopic behavior. That is due to the specific scheduling algorithms implemented in the operating system; there always are some constants (e.g. "time slice") and, at least with Windows, there even is some cheating as far as thread priorities go.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
this kind replies should be thrown into rubbish bin.
|
|
|
|
|
You shouldn't throw away knowledge. Instead you should accept reality as it is.
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]
|
|
|
|
|
Don't ask questions if you don't want to have answers.
Watched code never compiles.
|
|
|
|
|
The point of multithreading is to work in parallel on objectives that are not dependent on each other, and therefore don't care about order of execution.
If you do care about order of execution, use a single thread.
If you try to let your threads do only some things in a particular order, then you need synchronisation objects, such as a mutex or semaphore.
|
|
|
|
|
how to use the CFileDialog box to open the folder.....
i had done to open the .file extension which successfully opening but i am not able to open the folder plz help out this .....
|
|
|
|
|
sarfaraznawaz wrote: how to use the CFileDialog box to open the folder.....
Why not use SHBrowseForFolder() instead?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
CFileDialog automatically opens folders as they are selected by the user navigating a directory tree. Perhaps you could clarify your question.
The best things in life are not things.
|
|
|
|
|
i tried but not able to open or select the particular folder .....
here my code forit
void CfolderlockUIDlg::OnBnClickedAdd()
{
TCHAR szFilters[] = _T (" Allfolders(* *)¦* *¦¦");
CFileDialog dlg (TRUE, _T ("folder "), _T ("folders "),OFN_FILEMUSTEXIST |OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT, szFilters,this);
//CFileDialog dlg(TRUE,NULL,NULL,OFN_ALLOWMULTISELECT ,NULL,NULL,0);
if (dlg.DoModal () == IDOK)
{
filepath = dlg.GetPathName();
m_edit.SetWindowText(filepath);
}
}
by this it shows all the folder but i cant select the or open the folder
|
|
|
|
|
Do you want to select the folder or the the file inside the folder? if its the folder then you can use the function that was mentioned by David
here is an example for that
BROWSEINFO bi;
ZeroMemory(&bi, sizeof(bi));
TCHAR szDisplayName[MAX_PATH];
szDisplayName[0] = '';
bi.hwndOwner = NULL;
bi.pidlRoot = NULL;
bi.pszDisplayName = szDisplayName;
bi.lpszTitle = _T("Please select a folder for storing received files :");
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lParam = NULL;
bi.iImage = 0;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
TCHAR szPathName[MAX_PATH];
if (NULL != pidl)
{
BOOL bRet = SHGetPathFromIDList(pidl,szPathName);
if(FALSE == bRet)
return;
AfxMessageBox(szPathName);
}
and if you are selecting a file then you can see this example
SelectDialog - A Multiple File and Folder Select Dialog[^]
|
|
|
|
|
thanks its working.....
but one thing that its necessary to make browseinfo as zero memory ......
|
|
|
|
|
CString str;
str.Format(_T("All Files (*.dat)|*.dat||"));// change name .dat to any extension you want
CFileDialog file_dlg(TRUE,NULL,NULL,OFN_OVERWRITEPROMPT,str);
INT_PTR iRet = file_dlg.DoModal();

|
|
|
|
|
|
What do you mean 'passing arguments'? That code is complete and should compile and run without any additions.
The best things in life are not things.
|
|
|
|
|
I ran the program sucessfully with out put as "This sample takes a file name as a parameter".
Now i am having a file like c:\temp.txt and i want to know timestamp for this what is supposed to be done for this.
vikas da
|
|
|
|
|
You'll have to provide the name of the file as command line parameter.
For example lets consider the compiled executable is called TimeStamp.exe.
Execute the program from the command line (console): TimeStamp.exe c:\textfile.txt
As the name implies it, a command line parameter is passed from the command line.
In the code you've linked you can see how the parameter is accessed using the argv array.
modified on Monday, May 23, 2011 7:52 AM
|
|
|
|
|
I do not see any such exe in my Debug or Release folder,I am using VS 2008 Pro.
Apart from that i have to use this sample in one of my application to find the creation timestamp of a file,so help me achieving that same.
Thanks,
vikas da
|
|
|
|
|
The builded exe is in your Release and / or Debug folder. Look for it. I didn't say the exe will be called TimeStamp.exe at you local PC! It was just an example. The name of the exe depends on your Project Settings (the project name by default).
But then if you want to use only the logic shown in the code that you've linked in a program of yours, of course you don't need to build this exe at all but rather use the code that fullfills the desired task. And then again you dont have to provide the filename as command line parameter. This is totally up to you.
For the beginning .. it would for your case probably enough if you change the following line.
hFile = CreateFile(argv[1], GENERIC_READ, FILE_SHARE_READ, NULL,OPEN_EXISTING, 0, NULL);
The argv[1] here contains the file name. You could also hard code this filename like
hFile = CreateFile("C:\tmp.txt", GENERIC_READ, FILE_SHARE_READ, NULL,OPEN_EXISTING, 0, NULL);
You'd also have to remove this if you dont want the code to be dependent of the number of command line parameters..
if( argc != 2 )
{
printf("This sample takes a file name as a parameter\n");
return 0;
}
Or get the filename somewhere else. i dont know what you want to do but you'll have to think of stuff like that for yourself.
I strongly advise you to go through some basic C/C++ tutorials, since you seem to lack some basic understandings of the language here.
|
|
|
|
|
Having compiled and built this program you must have a program (xxx.exe?) in either your Debug or Release folder; check again. This is a simple console program that can be run in a command prompt window (are you really saying you do not understand this basic facility?) thus:
ProgramName C:\filename.txt
In order to add this functionality to your own project you can just copy and paste the relevant parts of the sample into your own project.
The best things in life are not things.
|
|
|
|
|
Maybe you should start here first.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
I have been working on SetupDi API functions with VC++ 2010 during these couple days. It works well with 32-bit and 64-bit debug-build, but not the 64-bit release-build. I added some AfxMessageBox 'es to narrow down where the problem was. It failed in the API SetupDiEnumDeviceInfo .
But when I formatted a CString in the error handling block after the SetupDiEnumDeviceInfo call, the problem was gone. It looks like some memory alignment issue (well, I guess). Anyone knows the correct way to resolve this kind of issue?
(1) The below code fails.
bool SetupDi::EnumDevInfo(DWORD dwIndex, SP_DEVINFO_DATA* pDeviceInfoData)
{
if(!m_hDevInfo) {
TRACE(_T("SetupDi::EnumDevInfo, m_hDevInfo is NULL. \n"));
return false;
}
if(!pDeviceInfoData) {
TRACE(_T("SetupDi::EnumDevInfo, pDeviceInfoData is NULL. \n"));
return false;
}
memset(pDeviceInfoData, 0, sizeof(SP_DEVINFO_DATA));
pDeviceInfoData->cbSize = sizeof(SP_DEVINFO_DATA);
BOOL bRet = SetupDiEnumDeviceInfo(m_hDevInfo, dwIndex, pDeviceInfoData);
if(!bRet) {
TRACE(_T("SetupDi::EnumDevInfo, SetupDiEnumDeviceInfo(index: %d) failed (0x%08X). \n"),
dwIndex, GetLastError());
}
return (TRUE == bRet);
}
(2) The below code works well.
bool SetupDi::EnumDevInfo(DWORD dwIndex, SP_DEVINFO_DATA* pDeviceInfoData)
{
if(!m_hDevInfo) {
TRACE(_T("SetupDi::EnumDevInfo, m_hDevInfo is NULL. \n"));
return false;
}
if(!pDeviceInfoData) {
TRACE(_T("SetupDi::EnumDevInfo, pDeviceInfoData is NULL. \n"));
return false;
}
memset(pDeviceInfoData, 0, sizeof(SP_DEVINFO_DATA));
pDeviceInfoData->cbSize = sizeof(SP_DEVINFO_DATA);
BOOL bRet = SetupDiEnumDeviceInfo(m_hDevInfo, dwIndex, pDeviceInfoData);
if(!bRet) {
TRACE(_T("SetupDi::EnumDevInfo, SetupDiEnumDeviceInfo(index: %d) failed (0x%08X). \n"),
dwIndex, GetLastError());
CString s;
s.Format(_T("SetupDi::EnumDevInfo, SetupDiEnumDeviceInfo(index: %d) failed (0x%08X). \n"),
dwIndex, GetLastError());
}
return (TRUE == bRet);
}
Maxwell Chen
|
|
|
|
|
Why the size of the passed memory is not passed by the EnumDevInfo caller (i.e. how could you be sure you have sizeof(SP_DEVINFO_DATA) bytes available?)?
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]
|
|
|
|
|
Because I am using it this way...
SetupDi DevInfo;
if(!DevInfo.GetClassDevs(SetupDi::eDC_System, _T("PCI"), true, true, true, false, false)) {
TRACE(_T("CFindDeviceDlg::FindDevice, GetClassDevs failed. \n"));
return false;
}
DWORD dwIndex = 0;
SP_DEVINFO_DATA spDevInfoData;
while(1) {
if(!DevInfo.EnumDevInfo(dwIndex, &spDevInfoData)) {
TRACE(_T("CFindDeviceDlg::FindDevice, EnumDevInfo failed. \n"));
break;
}
Maxwell Chen
|
|
|
|
|
It is the same project, isn't it?
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]
|
|
|
|