CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2001
    Posts
    1

    Console application with activex

    Hello

    I'm trying to combine VC6 console application with activex.

    I have bought activex that work fine with VC6 dialog based application.

    I add the activex to the dialog based application - and its work fine

    I need an example code of how to do it.

    Here is the code of the main CPP file:

    // ApaxTest.cpp : Defines the entry point for the console application.
    //

    #include "stdafx.h"
    #include "ApaxTest.h"
    // "apax.h" is the header file of the active x
    #include "apax.h"

    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif

    /////////////////////////////////////////////////////////////////////////////
    // The one and only application object

    CWinApp theApp;

    using namespace std;

    int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
    {
    int nRetCode = 0;

    // initialize MFC and print and error on failure
    if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
    {
    // TODO: change error code to suit your needs
    cerr << _T("Fatal Error: MFC initialization failed") << endl;
    nRetCode = 1;
    }
    else
    {
    // CApax is the activex class
    CApax Apax;
    Apax.SetCommPort(1);
    Apax.SetBaud(9600);
    Apax.PutString("atdt266\r");
    }

    return nRetCode;
    }

    Best Regards

    Nachum

  2. #2
    Join Date
    Sep 2002
    Posts
    77
    Call CoInitialize[Ex] or OleInitialize at the beginning of your _tmain (and CoUninitialize or OleUninitialize at the end).

  3. #3
    Join Date
    Aug 2002
    Location
    Madrid
    Posts
    4,588
    Is your object an ActiveX (COM object with all the IOLExxx interfaces), a COM control (i.e. COM object with UI), or a COM component ? If it is a component, the solution is very simple.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured