Page 1 of 1

C++ file help needed

Posted: Tue Jul 08, 2008 5:14 am
by ianhull
Hi all,

I am trying to capture the caller id from a program called YAC.
YAC sends caller ID information to YAC recievers using the follwing file.

Code: Select all

 
 
/*  YAC: Yet Another Caller ID Program - YAC Text Send Sample Program
 *  Copyright (C) 2002 Jensen Harris (jensen@sunflowerhead.com)
 *  http://www.sunflowerhead.com
 *
 *  YAC is free software; you can redistribute it and/or modify it under the
 *  terms of the GNU General Public License as published by the Free Software
 *  Foundation; either version 2 of the License, or (at your option) any
 *  later version.
 *
 *  YAC is distributed in the hope that it will be useful, but WITHOUT ANY
 *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 *  details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with YAC; if not, write to the Free Software Foundation, Inc.,
 *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *  File: YACTextSend.c
 *  Version: 1.0
 *  Last Modified: 11 September 2002
 *
 *  COMMENTS
 *  This program illustrates how you can communicate with YAC from your own
 *  code.  Although the sample program below is in C, it could have just as
 *  easily been in Visual Basic, Delphi, or even C#.
 *
 *  In order to send text through YAC, the YAC server must be running on
 *  your computer.  The steps necessary to communicate with YAC are:
 *
 *  1) Find the YAC message window.  This window has the class name
 *     "YACMainWindow".  If this window is not present, then YAC is not
 *     running.
 *
 *  2) Fill out a COPYDATASTRUCT structure with your string (max 300 chars)
 *     and the number of bytes.
 *
 *  3) Send YAC a WM_COPYDATA message with a pointer to your COPYDATASTRUCT
 *     struct as lparam.  YAC handles this message and will format, display,
 *     and broadcast your message to all listeners.
 *
 */
 
#include <windows.h>
 
#define MAX_CHARS   300
 
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
                   LPSTR lpCmdLine, int nCmdShow)
{
    HWND hwnd;
    COPYDATASTRUCT cds;
    TCHAR szText[MAX_CHARS];
 
    ZeroMemory(szText, sizeof(szText));
    ZeroMemory(&cds, sizeof(cds));
 
    // Find the YAC hidden window to send the message to
    hwnd = FindWindow("YACMainWindow", NULL);
 
    // If we didn't get a window handle back, YAC must not be running.
    if (!hwnd)
        return -1;
 
    // Grab the text from the command line
    strncpy(szText, lpCmdLine, MAX_CHARS - 1);
 
    // Fill out the COPYDATASTRUCT structure to pass to YAC
    cds.cbData = (DWORD)(strlen(szText) * sizeof(TCHAR));
    cds.lpData = (void *)szText;
 
    // Send the packed message to YAC
    SendMessage(hwnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
 
    return 0;
}
 
Could someone tell me how I could send the information to internet exploroer on windows?

What I mean is launch internet explorer and with the following additional params, C:\PROGRA~1\INTERN~1\iexplore.exe http://localhost/index.php?callerID=123456890

Any help greatly appreciated

thanks in advance

Re: C++ file help needed

Posted: Tue Jul 08, 2008 6:46 am
by Weirdan
What I mean is launch internet explorer and with the following additional params, C:\PROGRA~1\INTERN~1\iexplore.exe http://localhost/index.php?callerID=123456890
You can't do this with the code you provided because it expects the window it sending messages to to be already present (it won't launch anything).