By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,347 Members | 2,113 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,347 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?


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.

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

/// resources associated with this form.

/// </summary>

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








void Dispose(Boolean disposing)


if (disposing && components)






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


/// <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



// CallingAPI


this->CallingAPI->Location = System::Drawing::Point(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,


// Form1


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

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


this->Name = S"Form1";

this->Text = S"Form1";



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?


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

P: n/a

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.