Solved

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

Posted on 1997-10-30
9
514 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

832 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