|
You should make greater use of the MSDN documentation. This page[^] explains the values in the DWORD and how they may be used to get the specific characters of your edit string.
It's time for a new signature.
|
|
|
|
|
Hi,
Im getting the following error while closing handle using CloseHandle() function. Can anyone please tell how to resolve this issue?
First Chance Exception in test.exe(NTDLL.DLL):0xC0000008: Invalid Handle
Thanks,
|
|
|
|
|
The error message is pretty clear no ? You are passing an invalid handle to the CloseHandle function. Use your debugger inspect what might be wrong.
|
|
|
|
|
no.In that folder,im having a image file and Using FindFirstFile function i got handle for that image file. After trying to close that handle the application is getting crashed and it is showing this error.
wsprintf(szSearchFolder,"%s\\*.jpg","C:\\test");
hSearch = FindFirstFile (szSearchFolder, &Foldername);
if (hSearch == INVALID_HANDLE_VALUE)
{
return ERR_FAILED;
}
CloseHandle(hSearch);
|
|
|
|
|
Karthika85 wrote: CloseHandle(hSearch);
This is wrong. You should use FindClose() function to close the handle retured by FindFirstFile()
|
|
|
|
|
As Cedric said, you're passing an invalid handle to the function. Just because the value of the handle isn't INVALID_HANDLE_VALUE it doesn't mean the handle is valid. For example you might...
- be using a handle someone else has already closed
- you're using something uninitialised that contains some rubbish off the stack
- you're overwriting the variable containing the HANDLE value with a wild pointer write
- be doing something really perverse like HANDLE h( reinterpret_cast<HANDLE>( std::rand() ) );
So there's loads of ways a HANDLE can be invalid and not have a value of INVALID_HANDLE_VALUE.
Cheers,
Ash
|
|
|
|
|
I have intialized the handle value to NULL in the declaration.
HANDLE hSearch = NULL;
|
|
|
|
|
How about using FindClose()[^] as the documentation suggests instead of CloseHandle()?
|
|
|
|
|
Hey, well if the webserver hangs or something urldownloadtofile will keep trying to connect and somewhat hang there forever.
So iam in a need of a way to set a timeout for it, so itll stop executing after a set amount of time.
Maybe you guys have any idea how i could realise that?
And yes i do know winsock/wininet etc would be better but iam trying to learn my way up with easier functions for now .
Thanks
modified on Thursday, July 15, 2010 5:57 AM
|
|
|
|
|
Have you tried using the callback (last parameter) and return E_ABORT? That should probably be sufficient for you.
|
|
|
|
|
Well the program is stuck because the function URLDownloadToFile() wont stop executing if the destinationserver hangs so i cant do anything.
|
|
|
|
|
Once more: Have you tried what I suggested?
Here's a crazy thought: what if the callback is called back from the function repeatedly to allow you to monitor progress? And what if returning E_ABORT from that function will terminate the download attempt?
I know it's crazy, but you're allowed to be a little crazy on Thursdays.
|
|
|
|
|
If this API doesn't provide a timeout how about using an alternative? Use a HTTP client library (Alhem, Boost, IP*Works, Poco, Sharkengine) or one of the Windows HTTP APIs, e.g. WinHTTP (MSDN), Asynchronous WinHTTP Library (CodeProject).
See if it helps
/M
|
|
|
|
|
Hi All,
I am using _tfopen to read a specific file which will be accessed by multiple process simultaneously. This time _tfopen function getting failed and GetLastError() is returning the following error.
"The process cannot access the file because it is being used by another process."
This is how i called the function
_tfopen( csFileName_i.operator LPCTSTR(), _T( "rb" ))
I need to open the same file simultaneously by different process.
Please help me.
-Cvaji
|
|
|
|
|
Try using _fsopen[^] which allows file sharing.
It's time for a new signature.
|
|
|
|
|
Hi Experts
I am migrating one project from Vc 6.0 to Vc 8.0. I found one compilation Error regarding Enum.
In Vc 6.0 they have declared an enum in a class and again the same enum they are using in other class with scope resolution and have changed the enum value. It is compiling fine on Vc 6.0 but throwing an error while compiling in Vc 8.0.
Example code.
class CTest
{
public:
enum TestEnum {NA=0, First};
};
class CTest1
{
public:
enum CTest::TestEnum {Second, Third};
};
It is working fine in Vc 6.0 but throwing error in Vc 8.0
Error is:- error C2911: 'CTest::TestEnum' : cannot be declared or defined in the current scope
|
|
|
|
|
Listen to the compiler - the VC++ handling of enums changed significantly in either 2002 or 2003 - the code that compiled under VC++6 is just plain wrong, you can't open up enums and extend them the way you can namespaces.
All Microsoft compilers have a breaking changes document, have a look in that to see what else has changed and going to trip you up.
Ash
|
|
|
|
|
|
Hi all,
Please go through below function.
Copy any file/folder & then use this function to past Shortcut It is crashing "InvokeCommand".
Please help me.
void PasteShortcut()
{
try
{
CoInitialize(NULL);
IShellFolder* psf;
HWND hWnd = GetDesktopWindow();
HRESULT hr;
if (SUCCEEDED(SHGetDesktopFolder(&psf)))
{
IContextMenu* pcm;
if (SUCCEEDED(psf->CreateViewObject(hWnd,IID_IContextMenu,(void**)&pcm)))
{
HMENU hmenu = CreatePopupMenu();
if (hmenu != NULL) {
if (SUCCEEDED(pcm->QueryContextMenu(hmenu, 0,
0, 0xff,
CMF_NORMAL))) {
CMINVOKECOMMANDINFO cmi={0};
cmi.hwnd=hWnd;
cmi.cbSize=sizeof(cmi);
cmi.lpVerb= ".lnk";
hr= pcm->InvokeCommand(&cmi);
if (SUCCEEDED(hr)) {
MessageBox(hWnd, TEXT("Shortcut created"), TEXT("Message"), 0);
}
}
DestroyMenu(hmenu);
}
pcm->Release();
}
psf->Release();
}
CoUninitialize();
}
catch(...)
{
}
}
|
|
|
|
|
It looks like the content of your CMINVOKECOMMANDINFO structure is not complete; take a look at the documentation[^] for further details.
It's time for a new signature.
|
|
|
|
|
Hi Richard,
Thanks for reply...
now I have tried below code...
Below code is not showing crash as I have used "link" as lpVerb.
as you said I have provided all Content of CMINVOKECOMMANDINFO structure. "InvokeCommand" is return S_OK
But still Paste Shortcut is not happening on Desktop.
void PasteShortcut()
{
try
{
CoInitialize(NULL);
IShellFolder* psf;
HWND hWnd = GetDesktopWindow();
HRESULT hr;
if (SUCCEEDED(SHGetDesktopFolder(&psf)))
{
IContextMenu* pcm;
if (SUCCEEDED(psf->CreateViewObject(hWnd,IID_IContextMenu,(void**)&pcm)))
{
HMENU hmenu = CreatePopupMenu();
if (hmenu != NULL) {
if (SUCCEEDED(pcm->QueryContextMenu(hmenu, 0,
0 , 0xff,
CMF_NORMAL))) {
CMINVOKECOMMANDINFO cmi;
cmi.cbSize = sizeof(CMINVOKECOMMANDINFO);
cmi.fMask = 0;
cmi.hwnd = hWnd;
cmi.lpVerb ="link" ;
cmi.lpParameters = NULL;
cmi.lpDirectory = NULL;
cmi.nShow = SW_NORMAL;
cmi.dwHotKey = 0;
cmi.hIcon = NULL;
hr = pcm->InvokeCommand(&cmi);
if (SUCCEEDED(hr)) {
MessageBox(hWnd, TEXT("Shortcut created"), TEXT("Message"), 0);
}
}
DestroyMenu(hmenu);
}
pcm->Release();
}
psf->Release();
}
CoUninitialize();
}
catch(...)
{
}
}
|
|
|
|
|
Rahul Vaishnav wrote: But still Paste Shortcut is not happening on Desktop.
I don't see anything in the above that looks like a source file or a destination shortcut.
It's time for a new signature.
|
|
|
|
|
If anyone has previously used "TModule" in Borland C++, can you please let me know the equivalent(if any) class in win32 or atlease close to that class in similarity. I am migrating one of my application wrtten in borland C++ to visual C++. Just for your reference: "TModule in Borland C++ forms the basis for the TApplication class, which encapsulates the application's global functions such as startup tasks, message loops, and error handling. The TDll class provides a similar base for developing dynamic link libraries (DLL)."
modified on Thursday, July 15, 2010 4:03 AM
|
|
|
|
|
You would probably have much more answers if you describe which functionality you are looking for (for instance I never worked with Borland so I have no clue what this TModule does).
|
|
|
|
|
Thanks for your reply. I have modified my question including the details of what TModule is.
|
|
|
|