By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,688 Members | 1,860 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,688 IT Pros & Developers. It's quick & easy.

How to access API function of a Managed C++ application?

P: n/a
Hi all,

How to access API function of a Managed C++ application?

Sample:

This doesn't work. (::MessageBox.)

----------------------------------------------------------------------------
------------------------

#pragma once

namespace teste

{

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

/// <summary>

/// Summary for Form1

///

/// WARNING: If you change the name of this class, you will need to
change the

/// 'Resource File Name' property for the managed resource
compiler tool

/// associated with all .resx files this class depends on.
Otherwise,

/// the designers will not be able to interact properly with
localized

/// resources associated with this form.

/// </summary>

public __gc class Form1 : public System::Windows::Forms::Form

{

public:

Form1(void)

{

InitializeComponent();

}

protected:

void Dispose(Boolean disposing)

{

if (disposing && components)

{

components->Dispose();

}

__super::Dispose(disposing);

}

private: System::Windows::Forms::LinkLabel * CallingAPI;

private:

/// <summary>

/// Required designer variable.

/// </summary>

System::ComponentModel::Container * components;

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

void InitializeComponent(void)

{

this->CallingAPI = new
System::Windows::Forms::LinkLabel();

this->SuspendLayout();

//

// CallingAPI

//

this->CallingAPI->Location = System::Drawing::Point(96,
96);

this->CallingAPI->Name = S"CallingAPI";

this->CallingAPI->TabIndex = 0;

this->CallingAPI->TabStop = true;

this->CallingAPI->Text = S"linkLabel1";

this->CallingAPI->LinkClicked += new
System::Windows::Forms::LinkLabelLinkClickedEventH andler(this,
CallingAPI_LinkClicked);

//

// Form1

//

this->AutoScaleBaseSize = System::Drawing::Size(5, 13);

this->ClientSize = System::Drawing::Size(292, 266);

this->Controls->Add(this->CallingAPI);

this->Name = S"Form1";

this->Text = S"Form1";

this->ResumeLayout(false);

}

private: System::Void CallingAPI_LinkClicked(System::Object * sender,
System::Windows::Forms::LinkLabelLinkClickedEventA rgs * e)

{

::MessageBox(NULL, "Call API MessageBox Function",
NULL, NULL); /***********************HERE**********************/

}

};

}

And COM+, How to access ? Any Idea?

--

:o)
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Renato,

Renato T. Forti wrote:
How to access API function of a Managed C++ application?
Remember to include the windows.h header file!

In form1.cpp, it reads:

#include "Form1.h"
#include <windows.h>

Change this to:

#include <windows.h>
#include "Form1.h"

Now it should work.
And COM+, How to access ? Any Idea?


COM+ components are known in .NET as serviced components. See

MSDN Library
-> Visual Studio .NET
-> .NET Framework
-> Programming with the .NET Framework
-> Writing Serviced Components

Bart Jacobs

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.