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.
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.
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.
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:
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.
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?
bool SetupDi::EnumDevInfo(DWORD dwIndex, SP_DEVINFO_DATA* pDeviceInfoData)
TRACE(_T("SetupDi::EnumDevInfo, m_hDevInfo is NULL. \n"));
TRACE(_T("SetupDi::EnumDevInfo, pDeviceInfoData is NULL. \n"));
memset(pDeviceInfoData, 0, sizeof(SP_DEVINFO_DATA));
pDeviceInfoData->cbSize = sizeof(SP_DEVINFO_DATA);
BOOL bRet = SetupDiEnumDeviceInfo(m_hDevInfo, dwIndex, pDeviceInfoData);
TRACE(_T("SetupDi::EnumDevInfo, SetupDiEnumDeviceInfo(index: %d) failed (0x%08X). \n"),
// BEGIN: We just need this to make it work under x64. Memory alignment issue.
s.Format(_T("SetupDi::EnumDevInfo, SetupDiEnumDeviceInfo(index: %d) failed (0x%08X). \n"),
// END: We just need this to make it work under x64. Memory alignment issue.//AfxMessageBox(s);
return (TRUE == bRet);
Last Visit: 31-Dec-99 19:00 Last Update: 2-Dec-23 8:22