Re: VB6 DLL



Steve,

I understand that the ideal would be to do all of the serial work in the
main EXE. However, I want to hide what my software sends and receives to the
serial port and how it decrypts the data. I want to make a DLL that I can
distribute to allow third party customers to access my hardware without being
able to reverse engineer it.

The baud rate for the hardware is slow so the software is waiting for data
most of the time. It can process the data relatively fast. I setup an ActiveX
class with a MSCOMM control like this:

'top of class module
Public WithEvents MSComm1 As MSComm

'initialize in startup routine
Set MSComm1 = New MSComm

Should the OnComm event still trigger in this class when data is recieived?
My code in the on_comm event is not processor intensive and contains lots of
doevents during processing. It mostly just sits there and waits.

I can't figure out how to create a reference to the VB Timer control through
Project > References. I'll need this to tell if there has been a timeout or
lost connection with the hardware. With the timer control, I think I will
have all I need in the ActiveX class. Any ideas what OCX or DLL its in and
how I can create a new instance of a timer at run time?

Thanks for the help.

"Steve Gerrard" wrote:


"Jonathan" <Jonathan@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4C9B85FF-C804-49B1-A5B5-2327CC9174D2@xxxxxxxxxxxxxxxx
Hi,

I would like to make a DLL in VB6 that interfaces with a VB6 EXE. My concern
is that my DLL will be performing long operations with the serial port that
could take up to 2 minutes. My VB6 EXE needs to have some way to update its
GUI with the progress of the operation. After the long process, the DLL needs
to give the EXE data in a large array. I'm a little worried about threading
in VB6.


Well you should be. With a few exceptions, a VB app is strictly single threaded,
and in particular will explode if a second thread attempts to do anything to its
GUI elements.

An ActiveX DLL will not get you another thread. An ActiveX.Exe can do that, but
at the expense of another process as well, with the overhead of marshalling data
between processes, including your large array.

Unless you want to get really hard core about it, it seems to me a better
strategy is to setup the long operation in the main Exe, and then do lots of
work to make sure all processing is in steps, with DoEvents at appropriate
points if needed.

I believe you need to that anyway to work with a serial port effectively. You
typically are waiting for events from the serial port. As you respond to those,
you can update your GUI directly, or, if the code is in a class, raise a
progress event for the main form to receive. You then store the data received,
and go back to waiting for the next serial port event.




.



Relevant Pages

  • Re: mscomm in vc++ - parity error
    ... all ready to re-use, that use mscomm. ... have this new logger to write BUT I have a number of other loggers out there ... your own wrapper for serial port and i would suggest to make it a ... convert this class to dll with little effort. ...
    (comp.arch.embedded)
  • Re: Multiple DLL, multiple THREADS, multiple applications or something else?
    ... Once DLL is loaded and serial port opened and DLL left in its own ... especially if you re-use the buffers by ... > respond to query from devices on serial port) on a notify base ... ...
    (borland.public.delphi.language.objectpascal)
  • Re: Events do not fire when used in COM DLL
    ... This may be a problem in a COM dll but I don't know if it ... this creates the serial port component ... Enter a wait loop (tried Application.Processmessages and also ... The first button event loads the DLL and brings up a dialogue form. ...
    (borland.public.delphi.language.objectpascal)
  • Re: Conversing with a modem via a serial port
    ... There are a lot of ways of handling serial port communication, but most often I do two ... threads, one reading and one writing, using a port opened for asynchronous I/O. ... RS-485 network, including token recovery, token handoff, token acceptance, and read and ... It would never occur to me to use MSCOMM for any purpose; ...
    (microsoft.public.vc.mfc)
  • Re: Detecting outside contact ON/OFF state
    ... You could use your PC serial port and MSComm, by conneting your circuit to ... conneting the DTR output through the switch back to the input). ... Normal switch debouncing is done by the Windows serial API, so MSComm ...
    (microsoft.public.vb.general.discussion)