You do have a typelib or the DLL has an embedded typelib (else it would be
real hard to use it from VB6), right.
Take that typelib (.tlb) (or the DLL if you don't have a typelib) as
typelibname and run
tlbimp.exe typelibname /out:xxxx.interop.dll
- Run ildasm on the generated interop assembly and post the SendData method
declaration, I'm just curious to see how the second arg. is declared.
Willy.
"Minfu Lu" <Mi*****@discussions.microsoft.com> wrote in message
news:AD**********************************@microsof t.com...
| Nicholas,
|
| I do not have the original COM source code. This COM function interface is
| fixed (the second parameter must be an int32 address of a callback
function).
| How can I do it?
|
| Thanks,
|
|
| Minfu
|
|
|
| "Nicholas Paldino [.NET/C# MVP]" wrote:
|
| > Minfu,
| >
| > Most likely, you will have to create the COM interface declaration
| > yourself.
| >
| > --
| > - Nicholas Paldino [.NET/C# MVP]
| > -
mv*@spam.guard.caspershouse.com
| >
| > "Minfu Lu" <Mi*****@discussions.microsoft.com> wrote in message
| > news:32**********************************@microsof t.com...
| > > How to declare the delagate?
| > >
| > > "Nicholas Paldino [.NET/C# MVP]" wrote:
| > >
| > >> Minfu,
| > >>
| > >> You should be able to declare the parameter of type MethodInvoker
| > >> (which
| > >> is a delegate with the same signature). Then, it will pass the
address
| > >> of
| > >> the delegate to the COM object.
| > >>
| > >> The only thing you have to worry about here is storing the object
and
| > >> making sure it does not get garbage collected before your function is
| > >> done
| > >> executing (if it executes asynchronously, if it doesn't, then it
doesn't
| > >> matter). You need to store the object that has this method somewhere
so
| > >> that it doesn't get collected.
| > >>
| > >> Hope this helps.
| > >>
| > >>
| > >> --
| > >> - Nicholas Paldino [.NET/C# MVP]
| > >> -
mv*@spam.guard.caspershouse.com
| > >>
| > >> "Minfu Lu" <Minfu
Lu@discussions.microsoft.com> wrote in message
| > >> news:98**********************************@microsof t.com...
| > >> >I have a problem dealing with passing a function address to a COM
| > >> >callback.
| > >> >I
| > >> > use this COM function for communicating to a hardware. My original
| > >> > project
| > >> > was written in VB. I have converted it to C#. One of the problem is
| > >> > passing
| > >> > a function address to a COM function as a parameter with another
| > >> > progress
| > >> > value. My callback function is very simple using the progress value
to
| > >> > update
| > >> > my progressbar. Because this COM function usually takes a long time
| > >> > (sending
| > >> > a large mount of data to a hardware for example). In my old VB
project,
| > >> > it
| > >> > works fine. But when I convert it to C#, I do not know how to do
it. Is
| > >> > there
| > >> > anybody can help me to solve this problem?
| > >> >
| > >> > The following is the VB code:
| > >> >
| > >> > 'Declaration
| > >> > Dim ProgressValue As Long
| > >> > Dim objHardware As MyComLib.Hardware
| > >> > Dim FileName As String
| > >> >
| > >> > Private Form_Load()
| > >> > Set objHardware = New MyComLib.Hardware
| > >> > FileName = "C:\Test.bin"
| > >> > End Sub
| > >> >
| > >> > Private Sub cmdSendData_Click()
| > >> > Dim lAddress As Long
| > >> > lAddress = AddressOf UpdateProgressBar
| > >> > Call objHardware.SendData(FileName, lAddress, ProgressValue)
| > >> > End Sub
| > >> > Public Sun UpdateProgressBar()
| > >> > ProgressBar1.Value = ProgressValue
| > >> > End Sub
| > >> >
| > >> > Actually objHardware, ProgressValue and UpdateProgressBar are
defined
| > >> > in
| > >> > Module as public variables.
| > >> >
| > >> > Many thanks,
| > >> >
| > >> >
| > >> > Minfu
| > >> >
| > >> >
| > >>
| > >>
| > >>
| >
| >
| >