|
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.
|
|
|
|
|
Ok, but then you can create an MFC application, and some classes will be created for you, like a C...App class (the "..." being your project name). This class also wraps the message loop. It is probably not the same as the one for Borland but I guess it would be similar.
However, you'll need to choose if you want an SDI, MDI or dialog based application.
If you never worked with Visual Studio, I strongly suggest that you buy a book to get started, it will help you a lot at the beginning.
|
|
|
|
|
|
Hi,
in OnDraw() function i draw one 3d effect rectangle by the following code.
pDC->Draw3dRect(SwtRect2,WHITE,DARKGRAY);
By this code,the rectangle looks like 3d rect.
Like the same way can we do that for Ellipse.
I use Ellipse() fucntion but it draws only a flat elipse.
I want to draw like Radio button,so i want that.
Pls help me.
Anu
|
|
|
|
|
Draw3dRect was introduced in Win3.1 to paint those shadowed rectangles that are the buttons.
Radiobutton look& feel are actually small bitmaps coming form user.dll, hence there is no direct API call.
The trick is to draw two ellipses, the first offset-ed by (2,2) with a pen of size 2 and a grayed color, and the second of regular (1) size, no offset, over the first.
More sophisticated looks can be found drawing three of them, one offset-ed to bottom-right (grayed) and another offset-ed to top-left (lighted) and a third "normal".
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Hi,
Can any one send code to convert Modal dialog to modeless dialog & converting modeless dialog to modal dialog.
Thanks,
Venkat
|
|
|
|
|
Instead of the DoModal function, Call Create(), ShowWindow() function. Remeber, the CDialog object should not be local variable if you are calling Create() function. Other wise, the window will be destroyed when the object goes out of scope.
|
|
|
|
|
It's all described here[^].
It's time for a new signature.
|
|
|
|
|
Hi,
can any one send the code for converting SDI application to MDI application & code to convert MDI application to SDI application.
Thanks,
Venkat
|
|
|
|