Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VB5, Netscape, DDE & long word arrays...

Posted on 1997-10-30
9
515 Views
Last Modified: 2008-03-03
Via DDE, Netscape can return a list of its open windows (WWW_ListWindows). The value returned is a long word array. If I pass a long to WWW_GetWindowInfo, I'll get back the URL and the title, which I want.

My question is how within the confines of VB DDE handling do I parse what WWW_List Window returns?

Here's netscapes Doc:  see http://developer.netscape.com/library/documentation/communicator/DDE/ddeapi.htm

0
Comment
Question by:cellphone
  • 5
  • 4
9 Comments
 
LVL 6

Expert Comment

by:alamo
ID: 1439296
Well, unfortunately, you cant. The reason is that Netscape sends an array of longs as a straight binary array, not converted to ASCII. Dumb on Netscape's part (actually Spyglass wrote it originally) since there are therefore chr$(0) characters embedded in the data, yet most DDE (including VB's) expects text and terminates strings with chr$(0).

So you are stuck. I don't have VB5 available to test with but I can find nothing anywhere that says it is any different. I will post the code to process what you *should* be getting back, anyway - just in case, and so you can test as I tested. It actually works for the first window, since NS apparently starts numbering its windows at 1 and increments as each new one is opened.

Main code:
    DDE.LinkTopic = "netscape|WWW_ListWindows"
    DDE.LinkMode = vbLinkManual
    DDE.LinkRequest
    windowarray$ = DDE.Text
    While Len(windowarray$) > 0
        MsgBox (GetWindowInfo(GetNextDW&(windowarray$)))
    Wend

Public Function GetNextDW&(strdata$)
' Remove next 4 characters off strdata$
' and convert to a dw (long) which we return
' Pad strdata$ if it's <4 characters
  If (Len(strdata$) < 4) Then strdata$ = strdata$ & String$(4 - Len(strdata$), 0)
  dw& = Asc(Mid$(strdata$, 4, 1))
  If dw& > 127 Then dw& = dw& - 256
  For i% = 3 To 1 Step -1
    dw& = dw& * 256 + Asc(Mid$(strdata$, i%, 1))
  Next
  strdata$ = Mid$(strdata$, 5)
  GetNextDW& = dw&
End Function

Public Function GetWindowInfo$(win&)
    DDE.LinkTopic = "netscape|WWW_GetWindowInfo"
    DDE.LinkItem = win&
    DDE.LinkMode = vbLinkManual
    DDE.LinkRequest
    DDE.LinkMode = 0
    GetWindowInfo$ = DDE.Text
End Function

By the way, I searched for a DDE control which could handle binary data and was unsuccessful; perhaps with VB's callback capability you could actually use DDEML. DDEML should handle the binary data properly if you can get it to work at all when called from  VB.
0
 

Author Comment

by:cellphone
ID: 1439297
What is DDEML? And what would be involved in writing a C++ .dll that makes this call and passes back a normal comma/quote delimited array?
0
 

Author Comment

by:cellphone
ID: 1439298
What is DDEML? And what would be involved in writing a C++ .dll that makes this call and passes back a normal comma/quote delimited array?
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 6

Expert Comment

by:alamo
ID: 1439299
Thanks Bob, I really appreciate that. I gave a complete and correct and well-researched answer (to quote directly from your question) "within the confines of VB DDE handling". The rest of the solution is a new question, as you implicitly acknowledged when you posted a new message to Usenet asking for a solution, *quoting* *directly* *from* *my* *rejected* *answer*.

You have actually hurt your chances of getting an answer quickly on experts exchange since this question has mutated. The best solution for everyone would have been for you to accept my answer and post a new question.
0
 

Author Comment

by:cellphone
ID: 1439300
Whoa!! Your answer was in a nutshell: can't be done, unless you use DDEML. But you give no clue as to what that is. As far as I can tell I can accept an answer as is, or reject and as for clarification. Which is what I did. I'd as soon given you 3/4 credit and waited for a clarification, but that is not an available choice.

I will be more than happy to accept your answer if you clarify it. As for quoting you, consider it a compliment.
0
 
LVL 6

Accepted Solution

by:
alamo earned 200 total points
ID: 1439301
To answer your followup question -

Back in the old days or Win31 DDE was truly a mystical art, full of low-level Global Atoms and callbacks. MS figured out it was impossible to use (probably feedback from their own applications people) and so defined a higher-level interface, ddeml.dll. (An order of magnitude better, but still an order of magnitude below the ease of use of DDE in VB). Since then they have made the ddeml functions standard, so they now reside in user32 not in the separate 16 bit ddeml. So when I said "ddeml" I meant the Win32 DDE calls.

These calls can certainly be done in a C++ dll. Maybe even in VB (I am trying to figure this out right now, i have made some progress). No need to reformat the data, the restriction with chr$(0) is in the fact VB  puts the data into a control which uses chr$(0)-terminated strings. I will let you know.
0
 
LVL 6

Expert Comment

by:alamo
ID: 1439302
cellphone, I have succeeded in writing pure VB code to get the binary arrays from Netscape. Please grade this and post another question asking for it and I will answer. It took quite a while, I'd rather not post it on the end of this one. Thanks!
0
 

Author Comment

by:cellphone
ID: 1439303
Thanks very much - I'm looking foward to your answer.
0
 

Author Comment

by:cellphone
ID: 1439304
Will do. We seem to be in realtime here!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question