Hello all,
I've looked all over the internet and am not having much luck. I'm
trying to implement a callback out of a ftpgetfile method so I can give
my users an indication of the progress of their download since the
files are pretty big. I'm having problems setting up the callback
using the InternetSetStat usCallback method. I found a VB6 version, but
having all kinds of problems converting it to C#. I'm new to C#, so
I'm not all that familiar with event handlers, but I don't understand
how to use InternetSetStat usCallback or what it passes to the callback
method.
Does anyone have an example of this in C# or vb.net ?
Any help would be most appreciated.
Thanks,
Mark 2 3132
Hello Mark,
Take a look at this:
~
#Region "Declaratio ns"
Friend Declare Function InternetSetStat usCallback Lib "wininet.dl l"
( _
ByVal hInternet As IntPtr, _
ByVal lpfnInternetCal lback As INTERNET_STATUS _CALLBACK _
) As Integer
Friend Delegate Sub INTERNET_STATUS _CALLBACK( _
ByVal hInternet As IntPtr, _
ByRef dwContext As Integer, _
ByVal dwInternetStatu s As InternetStatus, _
ByRef lpvStatusInform ation As InternetState, _
ByVal dwStatusInforma tionLength As Integer _
)
Friend Enum InternetStatus
ResolvingName = 10
NameResolved = 11
ConnectingToSer ver = 20
ConnectedToServ er = 21
SendingRequest = 30
RequestSent = 31
ReceivingRespon se = 40
ResponseReceive d = 41
CtlResponseRece ived = 42
Prefetch = 43
ClosingConnecti on = 50
ConnectionClose d = 51
HandleCreated = 60
HandleClosing = 70
RequestComplete = 100
Redirect = 110
IntermediateRes ponse = 120
StateChange = 200
End Enum
Friend Enum InternetState
Connected = &H1
Disconnected = &H2
DisconnectedByU ser = &H10
Idle = &H100
Busy = &H200
End Enum
#End Region
Protected Overrides Sub OnClick(ByVal e As System.EventArg s)
MyBase.OnClick( e)
InternetSetStat usCallback(hInt ernet, AddressOf
InternetSetStat usCallback)
End Sub
Friend Sub InternetStatusC allback( _
ByVal hInternet As IntPtr, _
ByRef dwContext As Integer, _
ByVal dwInternetStatu s As InternetStatus, _
ByRef lpvStatusInform ation As InternetState, _
ByVal dwStatusInforma tionLength As Integer _
)
REM Handle callback
End Sub
~
It wasn't tested but should work.
Hope it will,
Roman
Thanks for the reply. I'll give it a try.
Temporarily, what I did was change to code to not use a FTPGetFile, but
InternetReadFil e instead since I have control over the buffer size.
My preference was to use FTPGetFile, so I'll give this is a shot.
Thanks again. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: scott ocamb |
last post by:
hello
I have implemented a solution using async methods. There is one async
method that can be invoked multiple times, ie there are multiple async
"threads" running at a time.
When these threads are complete, the call the Callback method. Each "thread"
calls the same callback method.
What thread does this callback method exist on? My testing indicates the
|
by: Boltar |
last post by:
Hello,
I am trying to use a CustomValidator control to perform client-side
validation via a server callback.
I have an example below that validates if a textbox contains an odd
number.
I realize that I can use client-side javascript entirely for this, I
have just created a simplified example. My actual callback validation
|
by: Robert |
last post by:
After failing on a yield/iterator-continuation problem in Python (see
below) I tried the Ruby (1.8.2) language first time on that construct:
The example tries to convert a block callback interface
(Net::FTP.retrbinary) into a read()-like iterator function in order to
virtualize the existing FTP class as kind of file system. 4 bytes max
per read in this first simple test below. But it fails on the second
continuation with ThreadError after...
|
by: ryan.mitchley |
last post by:
Hi all
I have a class (cPort) that is designed to receive objects and,
depending on the type, call a handler (callback) in any descendant of a
cProcessBlock class. Callback functions take a shared_ptr<cBaseas a
parameter, and return void.
The code was working fine, although I have encountered problems (under
a Microsoft compiler, of course - VC 8.0) when I attempt to add
callbacks to a class with multiple inheritance. I hate multiple
|
by: Jimmy |
last post by:
I need to use Asynchronous Socket functions in a server application and
am learning from sources such as the MSDN2
(http://msdn2.microsoft.com/en-us/library/bbx2eya8.aspx). What I
observed is that all callback handlers in examples are static
functions. I did try non-static callback handlers; they certainly
works, and they usually make my code simpler.
For example, a typical tutorial will start an asynchronous connection
with:
| |
by: Brian |
last post by:
Hi,
I've been trying to get a simple client / script callback to work. I
was using IE6 to the ASP Development Server / IIS 5 and it just
didn't work. I ended up using an example straight from an asp 2.0 book
and it still didn't work. However I noticed that it worked on firefox on
the development machine, and also IE6 and firefox from a remote machine.
I set various breakpoints and noticed that the firefox callback ends up
in the correct...
|
by: smmk25 |
last post by:
Before I state the problem, I just want to let the readers know, I am
knew to C++\CLI and interop so please forgive any newbie questions.
I have a huge C library which I want to be able to use in a .NET
application and thus am looking into writing a managed C++ wrapper for
in vs2005. Furthermore, this library has many callback hooks which
need to be implemented by the C++ wrapper.
These callback functions are declared as "extern C...
|
by: SQACPP |
last post by:
Hi,
I try to figure out how to use Callback procedure in a C++ form
project
The following code *work* perfectly on a console project
#include "Windows.h"
BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lparam)
{
|
by: Tim Spens |
last post by:
--- On Fri, 6/27/08, Tim Spens <t_spens@yahoo.comwrote:
I think I know where the problem is but I'm unsure how to fix it. When I call Register_Handler(...) from python via callback.setHandler1(callback1) this only seems to affect pythons ability to trigger an "event" in c. PyObject *Handler is always NULL even after I call Register_Handler(...). I thought there was some magic here that was assigning the pointer *Handler to my python...
|
by: Jef Driesen |
last post by:
I have a C DLL that I want to use from a C# project. The C header file
contains these declarations:
typedef void (*callback_t) (const unsigned char *data, unsigned int
size, void *userdata);
void myfunction (callback_t callback, void *userdata);
How do I translate this to C#?
I tried with:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |