Solved

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

Posted on 1997-10-30
9
508 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now