By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,587 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,587 IT Pros & Developers. It's quick & easy.

Capturing continuously emitted messages from a dll

P: 62
Hi Friends.
I'm new to VB 6.0 (SP6) and just managed to write my first dll.
This dll has some modules / procedures which are supposed to keep emitting strings (messages) based on what actions it is doing.

I want to know how should the dll be made so that once it is included in another Project (by adding a reference), the messages can be captured by the other application.

I'm not sure if what I state as an analogy is correct ...but would it involve creating a "stream" and sending strings to it ? If yes, can someone kindly share an example (or a link to an existing one). If not, [ more likely so :-) ], please guide me as to how this could be done.

Thanks in advance,
Parag P. Doke
Feb 5 '08 #1
Share this Question
Share on Google+
6 Replies


debasisdas
Expert 5K+
P: 8,127
What sort of string the DLL is returning ?
Why it is returning continuously ?
What if the target application does not capture the strings ?
Feb 5 '08 #2

P: 62
What sort of string the DLL is returning ?
Why it is returning continuously ?
What if the target application does not capture the strings ?
Hello debasisdas.
I was planning to have the dll print messages like the log4j with "INFO :" or "WARN :" or "ERROR:" or "FATAL:" at the beginning of the strings. The strings will have names of procedures being executed from the dll. So it might look something like this:
---Proc within dll---
Public Sub MyProc1(Arg1,Arg2)
LogString "INFO : Starting MyProc1(" & Arg1 & "," & Arg2 & ")"
LogString "WARN : MyObject is being reset"
LogString "INFO : Finished MyProc1(" & Arg1 & "," & Arg2 & ")"
End Sub
---Proc within dll---
All this pasted is fake code. I was looking for some method like LogString function which will add the strings to a queue / buffer / stream [sorry about the incorrect nomenclature]. The apps that will reference this dll are also being written by me (and I will request guidance on how to capture those strings in them too).

Thanks for looking into my request,
Parag P. Doke
Feb 5 '08 #3

Expert 5K+
P: 8,434
I'm out of my depth with creation of DLLs (definitely want to play with it, but never have the time), but could you implement it as an ActiveX control, and have it fire an event to pass each log string? That way, the using program can simply be coded to respond to the events or not.
Feb 6 '08 #4

P: 62
I'm out of my depth with creation of DLLs (definitely want to play with it, but never have the time), but could you implement it as an ActiveX control, and have it fire an event to pass each log string? That way, the using program can simply be coded to respond to the events or not.
Hello Killer.
Pardon my lack of knowledge about VB...but if I'm not mistaken, an ActiveX control would mean a forms based UI. I will be using this dll as a reference in (at least) 2 other applications. One of these would be console based and the other UI based.
I happened to find excellent console related code on this site:
http://vb.mvps.org/samples/project.asp?id=Console

Also, I read that VB.NET offers better support for streams (System.IO) and Console. Since I'm anyway new to both, I might as well try my luck with VB.NET. Any references to string handling between a dll and the referencing application are welcome.

Ummm....and by mentioning VB.NET my question no longer falls into the right forum / section. Let me see if I can try and move this elsewhere. Or maybe create a new post in the other one.

Thank you anyways for the suggestion. I'll try and learn more VB to reach a stage where I can fully understand and implement what experts like you share.
Feb 6 '08 #5

VBWheaties
100+
P: 145
Hi Friends.
I'm new to VB 6.0 (SP6) and just managed to write my first dll.
This dll has some modules / procedures which are supposed to keep emitting strings (messages) based on what actions it is doing.

I want to know how should the dll be made so that once it is included in another Project (by adding a reference), the messages can be captured by the other application.

I'm not sure if what I state as an analogy is correct ...but would it involve creating a "stream" and sending strings to it ? If yes, can someone kindly share an example (or a link to an existing one). If not, [ more likely so :-) ], please guide me as to how this could be done.

Thanks in advance,
Parag P. Doke
In your exposed dll class, create an event that consuming projects will handle:

Expand|Select|Wrap|Line Numbers
  1. Public Event MessageIncoming(msgText As String)
  2.  
In your consuming module (that is referencing the dll):

Expand|Select|Wrap|Line Numbers
  1. Public Withevents MyDLL As paragpdokeDLL
  2.  
That way, you will have events from your dll like the following:

Expand|Select|Wrap|Line Numbers
  1. Private Sub MyDLL_MessageIncoming(msgText As String)
  2.    If msgText = "Error" Then
  3.       'The dll is telling me there is an error
  4.    End If
  5. End Sub 
  6.  
And, of course, events need to be raised from your DLL project:

Expand|Select|Wrap|Line Numbers
  1.    Public Sub ErrorMessage (msgText As String) 
  2.       RaiseEvent MessageIncoming msgText
  3.    End Sub 
  4.  
Feb 6 '08 #6

Expert 5K+
P: 8,434
VB.Net is still considered to be VB, for the purposes of this forum. It's entirely possible you'll find more (or at least different) information in the .Net forum, and it may be well worth a try. But don't feel that you're not welcome in the VB one.
Feb 7 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.