Solved

boost for my simple DDE application

Posted on 2000-04-19
9
499 Views
Last Modified: 2008-02-26
Hi !
I want to build an app. which will monitor my IE and NetScape using DDE Services. But I don't know how to start that as I am a novice to DDE. Thus, I want some code for the client DDE which can connect to NETSCAPE and IE. and whenever a user goes to a web site, my app. can display that uRL in a messagebox. I am already lost in the wilderness of MSDN. So, please help me with some code sample.

I had written a small dialog based  app. to act as a DDE client, but it's not working the correct way.....    :-(

These are the things I had implemented :

the constructor of app. lok likes :

extern DWORD dwidInst;   //Global variable

CNetAccessApp::CNetAccessApp()
{
      // Initialization of dde application.
      if(DdeInitialize(&dwidInst, LocationDdeCallBack, APPCLASS_MONITOR|MF_POSTMSGS|MF_CONV|MF_CALLBACKS, 0ul)){
            dwidInst = 0UL;
      }
}


then in the OnInitDialog() of my dialog class, I had written the following code :

int OnInitDialog()
{

      CDialog::OnDialog();      
      HCONV hConv = NULL;
      CString csItem = "";
      CString csTemp = "";

      
      if(dwidInst == 0UL){
                  MessageBox(NULL,"Dde Initialization Failed...","Error", MB_OK);
                  return;
      }
      
      //Connect to the Netscape server.
      HSZ hszService = DdeCreateStringHandle(dwidInst, "NETSCAPE", CP_WINANSI);
      hConv = DdeConnect(dwidInst, hszService,0L, NULL);
      
      // Check for the connection
      if(hConv == 0UL){
            char *sTemp = "Unable to start convertion with NETSCAPE...";
            MessageBox(NULL,sTemp, "Error", MB_OK);
            return;
      }

      CString csItem;

      //This seems to be a bottlenect. Please guide me how can I decide the correct values for csItem
      csItem="0";

      HSZ hszItem = DdeCreateStringHandle(dwidInst, csItem, CP_WINANSI);
      HDDEDATA hRetVal = DdeClientTransaction(NULL, 0ul, hConv, hszItem, CF_TEXT, XTYP_ADVSTART, 5000L, NULL);
      //UINT k=DdeGetLastError(dwidInst);
      //The hRetValue always comes out to be 0 ?????
      //The value of k tells INVALID PARAMETER
}

//My Call back functions looks like this:
//Just to know which all messages i am receiving

HDDEDATA CALLBACK LocationDdeCallBack(UINT type, UINT fmt,
      HCONV hconv, HSZ hsz1, HSZ hsz2, HDDEDATA hData, DWORD dwData1,
      DWORD dwData2)      {
      CNetObj cn;

      CString c2 = cn.GetString(hsz1);
      if(!c2.IsEmpty())      AfxMessageBox(c2);

      switch(type){
      case      XTYPF_NOBLOCK:
            AfxMessageBox("XTYPF_NOBLOCK");
            break;
      case      XTYPF_NODATA:
            AfxMessageBox("XTYPF_NODATA");
            break;
      case      XTYPF_ACKREQ:
            AfxMessageBox("XTYPF_ACKREQ");
            break;
      case      XCLASS_MASK:
            AfxMessageBox("XCLASS_MASK");
            break;
      case      XCLASS_BOOL:  
            AfxMessageBox("XCLASS_BOOL");
            break;
      case      XCLASS_DATA:
            AfxMessageBox("XCLASS_DATA ");
            break;
      case      XCLASS_FLAGS:    
            AfxMessageBox("XCLASS_FLAGS ");
            break;
      case      XCLASS_NOTIFICATION:
            AfxMessageBox("XCLASS_NOTIFICATION ");
            break;
      case      XTYP_ERROR:
            AfxMessageBox("XTYP_ERROR ");
            break;
      case      XTYP_ADVDATA:
            AfxMessageBox("XTYP_ADVDATA ");
            break;
      case      XTYP_ADVREQ:
            AfxMessageBox(" XTYP_ADVREQ");
            break;
      case      XTYP_ADVSTART:
            AfxMessageBox("XTYP_ADVSTART ");
            break;
      case      XTYP_ADVSTOP:
            AfxMessageBox(" XTYP_ADVSTOP");
            break;
      case      XTYP_EXECUTE:
            AfxMessageBox("XTYP_EXECUTE ");
            break;
      case      XTYP_XACT_COMPLETE:
            AfxMessageBox("XTYP_XACT_COMPLETE ");
            break;
      case      XTYP_REGISTER:
            AfxMessageBox("XTYP_REGISTER ");
            break;
      case      XTYP_UNREGISTER:
            AfxMessageBox("XTYP_UNREGISTER ");
            break;
      case XTYP_CONNECT :
            AfxMessageBox("XTYP_CONNECT ");
            break;
      case XTYP_CONNECT_CONFIRM :
            AfxMessageBox("XTYP_CONNECTCONFIRM ");
            break;
      case XTYP_DISCONNECT :
            AfxMessageBox("XTYP_DISCONNECT ");
            break;
      case XTYP_POKE :
            AfxMessageBox("XTYP_POKE ");
            break;
      case XTYP_REQUEST :
            AfxMessageBox("XTYP_REQUEST");
            break;
      }
      return (HDDEDATA) NULL;
}


/*
Right now when i run this application i only get XTYP_REGISTER message when i starts netscape,
and XTYP_UNREGISTER when i closes the netscape browser
and nothing else
*/

I am a novice to DDE programming and MSDN samples are too bulky for me...
 so please guide me and tell me what's wrong with the code

I just want to receive all the URL addresses that the user is visiting.



0
Comment
Question by:sun307
  • 5
  • 4
9 Comments
 
LVL 2

Expert Comment

by:abesoft
ID: 2732224
Your parameter to XTYP_ADVSTART is wrong.  It needs to specify the topic that you are interested in, instead of just "0".

But I think that you should really try looking at: http://developer.netscape.com/docs/manuals/communicator/DDE/abtdde.htm

and, more specifically:
http://developer.netscape.com/docs/manuals/communicator/DDE/ddevb.htm#www_registerurlecho

Which, I think, is closer to what you really want to do.

(IE uses a similar enough DDE interface, so your code should be able to run off of both.  Your milage may vary.... ;)
0
 
LVL 2

Author Comment

by:sun307
ID: 2732812
thanx abesoft!
I had tried that but couldn't figure out the correct parameter. the netscape document for www_registerurlecho just has the following lines and it's dificult to make out the parameter from there :
WWW_RegisterURLEcho
Netscape is: Server.

Transaction Type: XTYP_POKE.

Item (Arguments): qcsServer
qcsServer is the DDE server that wishes to receive WWW_URLEcho topics.

Description: This topic registers qcsServer to be notified when the loading of a URL occurs, via the WWW_URLEcho topic. Multiple servers can be registered with this topic. None are denied registration. The SDI draft at the time this document was written indicates the transaction type as XTYP_REQUEST, which is a possible incompatibility.
0
 
LVL 2

Author Comment

by:sun307
ID: 2733930
This question has a deletion request Pending
0
 
LVL 2

Expert Comment

by:abesoft
ID: 2752157
This question no longer is pending deletion
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 2

Accepted Solution

by:
abesoft earned 300 total points
ID: 2752158
Try:
csItem="myServerName";

HSZ hszItem = DdeCreateStringHandle(dwidInst, csItem, CP_WINANSI);
// register your server name
DdeNameService( dwidInst, csItem, 0, DNS_REGISTER);
// Ask NS to send URL's to that server.
HDDEDATA hRetVal = DdeClientTransaction(NULL, 0ul, hConv, hszItem, CF_TEXT, XTYP_REQUEST, 5000L, NULL);
// Or maybe XTYP_POKE?

For "myServerName", you should substitute the name of your DDE server.  You will also need to call DdeNameService to unregister your server name before termination.
0
 
LVL 2

Author Comment

by:sun307
ID: 2754243
Hi abesoft!
can u clarify one more point....
does the same application can work for IE too ....????
0
 
LVL 2

Expert Comment

by:abesoft
ID: 2755322
I did this unser IE and Netscape about five years ago, and the same thing worked for both of them.  (There may have been differences, but they were minor.  The service names were different, obviously.)

Oh, by the way, I didn't compile or test the code snippet that I gave you, so you may need to massage it to get it to fit.  Good Luck!
0
 
LVL 2

Author Comment

by:sun307
ID: 2952040
Answer accepted
0
 
LVL 2

Author Comment

by:sun307
ID: 2952041
Thanx and I am sorry for accepting ur answer so late
_Regards
sun307
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

708 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

12 Experts available now in Live!

Get 1:1 Help Now