Click here to Skip to main content
15,879,474 members
Everything / Programming Languages / C++/CLI

C++/CLI

C++/CLI

Great Reads

by Dark Daskin
Article describes how to build an assembly that exposes functions to unmanaged code without C++/CLI
by Stoyan Damov
Internet File System from scratch - making web services and peer-to-peer technology work together to build a virtual file system
by Nish Nishant
Demonstrates the usage of splitters, treeviews, listviews, panels, toolbars
by Alexey
The ALXGrid Control Library is a set of classes for management of data as a table.

Latest Articles

by Mark Birbeck
Easily and quickly build web services clients using XForm
by Shao Voon Wong
Consuming Your C# Library in MFC/C++ Project via C++/CLI
by Mehul Donga
Handle managed (C#) event in managed (C++/CLI)
by Abhineet Ayan Verma
Major calling conventions for Win32 and best suited functions

All Articles

Sort by Score

C++/CLI 

27 Jun 2009 by Dark Daskin
Article describes how to build an assembly that exposes functions to unmanaged code without C++/CLI
28 Sep 2002 by Stoyan Damov
Internet File System from scratch - making web services and peer-to-peer technology work together to build a virtual file system
3 Jul 2002 by Nish Nishant
Demonstrates the usage of splitters, treeviews, listviews, panels, toolbars
10 Nov 2002 by Alexey
The ALXGrid Control Library is a set of classes for management of data as a table.
25 Jan 2012 by Sebastian Krysmanski
The help page for IDisposable provides the code for IDisposable's default implementation pattern in C#. This article will explain each part of it step by step and also provide the equivalent C++/CLI code in each step.
5 Jul 2008 by Nish Nishant
This article walks through the implementation of a C++/CLI class from a disposable C# base.
24 Jul 2008 by bollwerkj
This article shows you how I got Excel to work using C++/CLI in a Windows Forms Application
25 Sep 2008 by Rajesh R Subramanian
Of all your questions I've attempted, this is the toughest one, Christian.First off, .NET and C++ (I will say only C++ in this message. But, When I say C++, include the frameworks and libraries built on and around it - MFC, ATL, WTL, etc.,) are...
30 Oct 2001 by Nish Nishant
Shows how you can pass data to your worker threads
31 Oct 2001 by Nish Nishant
Introduction to using the Monitor class for accessing shared resources from multiple threads
4 Apr 2014 by Pragmateek
Using C# from native C++ with the help of C++/CLI.
17 Jun 2002 by Chris Maunder
A quick introduction to Garbage collection in .NET using Managed C++
18 Dec 2012 by Lars [Large] Werner
Windows has built inn support for a lot of keyboard languages, this class makes it possible to extract that info in an easy manner and present it to screen.
20 Apr 2009 by Inaki Ayucar
Learn how to sign C++/CLI assemblies with a strong name.
12 Jun 2002 by Nish Nishant
Tutorial on creating your own collection classes that are enumerable and sortable. Explains in detail the usage of the IEnumerable, IEnumerator, IComparable and IComparer interfaces
26 Jan 2012 by paladin_t
A guide about how to mix native and managed code in one solution
23 Dec 2008 by odlumb
How to launch and manipulate applets programmatically.
13 Aug 2009 by Stuart Dootson
The way I'd approach it is like this:1. Define functions that return random voewls and random consonants - here's a random vowel function:char RandomVowel(){ const char vowels[] = {'a', 'e', 'i', 'o', 'u'}; // Use rand() to get a number...
12 Oct 2009 by Jörgen Sigvardsson
In addition to what Stuart said, if you really don't want to change the function signature from floatto double, you can always use literals that are typed as float. If you add the suffix f to the floating point numbers, they will be typed float.Your examples would then be function(1.2f, 2f) and func
7 Feb 2012 by ErnestoNet
User Control with scrolling and zooming done in C++/CLI
6 Mar 2011 by Sergey Alexandrovich Kryukov
This is no such thing as "adding reference" to executing assembly. You have to add (load) assembly itself.You either load all assemblies statically during compilation or load and use a new assembly during run-time. This way you can develop plug-ins to your system: you can locate the class...
11 Apr 2023 by Shao Voon Wong
Consuming Your C# Library in MFC/C++ Project via C++/CLI
22 Aug 2008 by Perspx
I don't know about removing power but you can lock volumes with DeviceIoControl() with the FSCTL_LOCK_VOLUME which means that your process has exclusive access to that volume. Take a look at the documentation here. You could do this with the CD...
17 Oct 2009 by Rajesh R Subramanian
hanlei0000000009 wrote:I need my program sleep 1 microsecond, but Sleep() can not do this.Neither can any other API do this (under Windows). Windows was never designed to provide this kind of functionality (it is not a real-time OS). If you use something like Sleep(2), your program may sleep for 2 m
16 Mar 2011 by Sergey Alexandrovich Kryukov
OK, as OP expressed interest in my alternative way of working with dynamically compiled assemblies, I'm starting to sketch the design.Introduction: I used to develop some designs for adding assemblies dynamically or during run-time. One option is to add assemblies from executable files. Such...
19 Jul 2016 by Christian Koberg
Console output, general applicable to all executables on a Windows system
22 Aug 2008 by Jijo.Raj
ameyakoshti wrote:1st of all i want to know whether it is possible to disable usb portsTo disable USB ports, check this[^]. You have to programatically access the registry and set the key.ameyakoshti wrote:and CD rom "POWER" through VC++.I hope...
30 Jan 2009 by CPallini
"text && text" If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.This is going on my arrogant assumptions....
19 Apr 2012 by CPallini
You should validate the pair {day, month} immediately after the user inputs them, you may use, for instance (warning, not tested), the following function:// returns 1 on successfull validation// 0 otherwiseint validate(int day, int month){ if (day
17 Dec 2012 by Christian Graus
Nope, you can't. Not without buying an expensive tool that creates unreadable code
10 Sep 2013 by CPallini
const char * myBrainHurts(int n){ static const char * ans[] = {"Number is even", "Number is odd" }; return ans[n % 2];}
22 Aug 2008 by vikas amin
its simple by modifying the registery , check this linkhttp://forums.msdn.microsoft.com/en-US/vcgeneral/thread/15469774-bd67-4bed-b797-32a899eb79d3[^] Vikas AminMy First Article on CP" Virtual Serial Port "[^]modified on Thursday, July 24, 2008...
2 Aug 2009 by «_Superman_»
In an executable, there must be one entry point that can be called by the loader, runtime etc.There cannot be any ambiguity here.That is why we can have only one main function in a console program and only one WinMain function in a windows...
8 Aug 2009 by David Crow
See here. "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." -...
13 Feb 2009 by «_Superman_»
SetEndOfFile can be used to extend or truncate a file. «_Superman_»
18 Feb 2011 by Nish Nishant
They decided to use that style for Managed C++ and C++/CLI (only the automatic designer does that though). I reckon they wanted to be similar to C# (where there is just one file, no separate declaration and definition files).That said you can choose to keep them in separate files if that...
12 May 2011 by Yusuf
[In support of @OriginalGriff Answer:]using memmove you will gain performance but at an expense of readability and a chance to shoot yourself in the foot. Remember you are dealing with raw mem locations and slight shift can have.... you know what I mean.If you are dealing with small set...
3 Aug 2008 by hoxsiew
int count; // Loop counter variableint correct;char correct_answers[count] = {B, D, A, A, C, A, B, A, C, D, B, C, D, A, D, C, C, B, D, A}This can only cause problems. correct_answers[count] should probably be correct_answers[NUM_QUESTIONS] since...
1 Aug 2009 by Bacon Ultimate Cheeseburger
Simply make a call to GetObjectType().
13 Aug 2009 by Stuart Dootson
Using Spy++ on a sample application I just built, it would seem that instead of edt1, you now want to use cmb13 (0x47c). I guess they decided that as that field is (now) actually a combo-box, that would be a better ID to use. Java, Basic, who...
13 Oct 2009 by Cedric Moonen
No, you can't select the type of the class this way. However, by using pointers (or references), you can manipulate all buildings the same way by manipulating pointers to the base class (this is called polymorphism, google for it if you want more information).What you want are virtual constructors,
12 Feb 2011 by Nish Nishant
I believe you were asking about the equivalent C++/CLI syntax, if so here goes:generic ref class GenericList{public: T GetNext() { T temp = T(); return temp; }};In the above code snippet T() is identical to default(T) in C#, and will...
11 Mar 2011 by Nuri Ismail
What you need is called Context Menu Shell Extension. There are excellent articles on Shell Extension in CodeProject.I recommend you to check out this[^] article series. In Part 1[^] and Part 2[^] you will find very useful information. :)
29 Mar 2012 by barrd
Fix an exception related to ISupportInitialize.BeginInit and learn why it happens.
8 Nov 2012 by AthosXtreme
How to build a .NET wrapper to send MaxL commands to Essbase.
5 Aug 2012 by Volynsky Alex
Please read the following instructions :http://www.ibm.com/developerworks/library/os-ecl-vscdt/[^]http://www.eclipse.org/resources/resource.php?id=291[^]I hope it will help you :)
8 Oct 2012 by Espen Harlinn
I guess you are looking for something like this: Erasing Files Securely[^]Best regardsEspen Harlinn
22 Oct 2013 by Dave Kreskowiak
Stop before you go any further with this project.Read up on the Distributed File System that is built into Windows SERVER already.This is a SERVER technology, not workstation. Workstations cannot be part of a DFS. They must be Windows Server based shares.You have a very large...
21 Nov 2013 by CPallini
See this Stack Overflow question: "What is the best way to convert between char* and System::String in C++/CLI"[^].
19 Jul 2015 by Stefan_Lang
First, lets be clear about one thing: if you need to access container elements by index, then you shouldn't use a list! There is no index operator for std::list, because it simply doesn't make sense! Think about your use cases, i. e. what, exactly you want to do with your container: how you...
19 Aug 2002 by Soliant
Use Managed C++ as your code-behind file for ASP.NET web pages
22 Sep 2008 by Christian Flutcher
I am progressing with my C++ learning. I am stuck with the following code. void ChangeData(int** ptr){ int ab = 1000; // scope in this method *ptr = &ab;}int _tmain(int argc, _TCHAR* argv[]){ int a = 10; int* aPtr = &a; ChangeData(&aPtr); cout...
22 Sep 2008 by Russell'
The variable is destroyed, but not the contents.You know the abbress s you can continue to check it's value...but, as you sad, it is wrong, so do not do it. The system can use the same locatio of that variable in any moment after that the...
22 Sep 2008 by Cedric Moonen
Christian Flutcher wrote:I am confused how this is happening?Because you were lucky (or in your case, not ). In your ChangeData function, your local variable has a certain address which you store in your ptr variable. When the function exits,...
10 Oct 2008 by led mike
Gut Mikh Tappe wrote:Please let me know what to do Ok I will try. What you need to do is read the documentation.[^]Also reading this might help as well.[^]In my experience not all authors match every reader. So if you find reading those sources...
10 Dec 2008 by Kiran Pinjala
Hi,I have creted a MFC SDI project in VC 2008 and compiled in Vista OS. Now when i copied the project into XP OS system and opened. I can open all views(class view, solution explorer...) but the resource view...it is showing a MessageBox statingA...
29 May 2009 by «_Superman_»
Call GetLogicalDrives to get all the available drive letters.Call GetSystemDirectory to get the drive which contains the OS.Open the volume using CreateFile("\\.\C:", ...Here replace C: with the drive letter returned in GetSystemDirectory.Call...
1 Jul 2009 by David Crow
Caslen wrote:If it is my problem is there anyway to detect programatically whether a file is already open somewhere else?Open it exclusively. All other attempts will fail. "Old age is like a bank account. You withdraw later in life what you...
1 Aug 2009 by «_Superman_»
OnCreate is called just when the application requests that the Create function be called. So it is not guarenteed that the window is fully created. OnInitDialog is called after the window (in this case the dialog) is completely created.When you...
16 Oct 2009 by Stuart Dootson
Yeah, that's not happening...Why 1 microsecond, FFS? What are you trying to do? Because there may well be a better way.
3 Apr 2009 by David Crow
The union looks something like this:-----------------------| 512 |-----------------------| 00000010 | 00000000 |-----------------------| 2 | 0 |----------------------- "Old age is like a bank account. You withdraw...
2 Apr 2010 by Sauro Viti
The fxsave instruction could be used both in user and kernel mode, but you are missing a constraint: the destination adress of that operation must be aligned on 16 bytes boundaries (see Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 2A at page 3-455).The problem is that...
16 Oct 2010 by Aescleal
If you're using C++ there's no reason to use printf or the whole god awful family of C relics. Use a stream. Then you get type safety and you won't try reading return addresses off the stack to interpret as strings. Consider rewriting along the lines of:int main(){ int d = 20; ...
3 Dec 2010 by #realJSOP
We don't do homework for people. It's not that we feel like we're too good to do it, or even too busy, but it's because part of learning how to be a programmer is learning how to analyze the problem, design a solution, and finally, implement that solution. You're not learning ANYTHING by...
23 Dec 2010 by T2102
Basically a pointer that may be moved by the garbage collector^ floating pointer% floating reference
23 Dec 2010 by Cedric Moonen
This is not C++, this is managed C++. If you want to code in pure C++, forget about it.
27 Jan 2011 by CPallini
Function names in C/C++ are actually function pointers. And yes, of course, you may pass a function pointer to a template function. :)
5 Mar 2011 by Sergey Alexandrovich Kryukov
Probably you're messing up the names of enumeration members with their underlying integer values. Look at the sample of usage if this attribute here: http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlenumattribute.aspx[^].The serialization mechanism for enumeration is based...
9 Mar 2011 by Ger Hayden
I am using XSD.exe to generate C# classes corresponding to my schema which are consumed by a C++/CLI app to produce XML documents based on the schema, but I am not comfortable with it for a couple of reasons.1. I cant read the schema information from the autogenerated class, therefore.2....
12 Mar 2011 by Espen Harlinn
You need to access an instance object of your Form1 class - you can do something like this:1. Add the following to your Form1 class definition - leaving label1 as a public field is usually not considered a good idea.public: void SetLabel1Text(String^ txt) { label1->Text = txt;...
11 Mar 2011 by Espen Harlinn
I believe you may find this interesting:http://www.boost.org/doc/libs/1_46_0/libs/filesystem/v3/doc/tutorial.html[^] - it will even work on other os'esYou can also usehttp://www.boost.org/doc/libs/1_46_0/libs/regex/doc/html/index.html[^] to facilitate quite advanced search...
8 Apr 2011 by David J Perez
I have C# application that needs to interface with a native (unmanaged) DLL. The native DLL exposes its library through a C++ Class, so I decided to wrap the class with a C++/CLI DLL to be able to use it in the C# app. The problem centers on the implementation of a wrapper method within...
8 Apr 2011 by Nish Nishant
If you are willing to allow the managed clients to dictate when they no longer need the wrapper, you can implement the Dispose-pattern. In C++/CLI Disposing is the same as calling delete on the reference handle, and at this point the wrapper can call a method in Native_eh (something like...
15 Apr 2011 by Guyverthree
You need to changeString^ data = serialPort1->ReadExisting();StreamWriter^ sw= File::AppendText(fileloc->Text);sw->WriteLine(data);sw->Flush();sw->Close(); toString^ data = serialPort1->ReadExisting();StreamWriter^ sw=...
22 Apr 2011 by Nish Nishant
You need to call ReadByte in a loop until it returns -1. And then you can probably use File::WriteAllBytes to write it to a file. If you want to append to the file, you'd need to write more code (something similar to what you already have now.And I don't think it makes sense to display...
28 Apr 2011 by Prerak Patel
usesw->Write...
6 Jul 2011 by Sergey Alexandrovich Kryukov
Compilation error: function "Better" is not defined. Compilation aborted.By the way, I'm just curious: do you plan to learn just one language? I would call this idea somewhat risky. You need to learn programming, not just language.—SA
10 Jul 2011 by Ashish Tyagi 40
I guess you already have that list of blocked sites and you are writing code for block them and redirect to your default redirecting site.. It is a very basic functionality of a standard firewall... Well for blocking or allowing any site requested from the browser you must capture those...
11 Jul 2011 by Christian Graus
Use Convert.ToChar on your values, or use a format specifier. Here,[^] they are the same for all .NET languages.
19 Jul 2011 by lukeer
I may very well be wrong, but your code looks a lot more like C++ than C#.As for your question, WindowsForms provides a class BackgroundWorker in the System.ComponentModel namespace. It's a very convenient way of using a separate thread. MSDN[^] gives an example on how to use it.To put...
17 Aug 2011 by Ger Hayden
This is a working example of a BLOB column on a DataGridView for a Windows Form using C++/CLI where data is drawn from an XML document.
16 Nov 2011 by Sergey Alexandrovich Kryukov
Something like that:ListBox ListBoxLog = new ListBox();//...internal void Log(string message) { ListBoxLog.Items.Add(message); ListBoxLog.SelectedIndex = ListBoxLog.Items.Count - 1;}You may also want to make it thread-safe, more exactly, to make it possible to add...
4 Aug 2012 by Volynsky Alex
Please look following...
16 Oct 2012 by Sergey Alexandrovich Kryukov
It looks like you have no clue on how exceptions work. Just learn about it — it's not trivial. A hint: exception is something which works on a whole stacks (of each tread separately, of cause) and jumps over the stack to the trial point ignoring the history of calls and returns. This is a...
26 Oct 2012 by fjdiewornncalwe
Use event based communication. That way your UI conforms to proper coding etiquette.// In Form1 codeprivate void OnOpenForm2Click(object sender, EventArgs e){ var form2Obj = new Form2(); form2Obj.Shown += (o, args) => { btnOpenForm2.Enabled = false; }; form2Obj.FormClosed +=...
11 Apr 2013 by CPallini
You should put your drawing stuff inside the Form::Paint event handler, see Control::Paint Event[^].
3 May 2013 by Sergey Alexandrovich Kryukov
You can do it by doing some really thoughtful, beautiful design and development work, based on beautiful experience. The common recommendations cannot fit in a Quick Answer, but please see some of my past answers:GUI Apperance - C#.Net [in brief],GUI Apperance - C#.Net [more detailed],Code...
24 May 2013 by Sergey Alexandrovich Kryukov
I have no idea how this particular engine works, but I'm pretty certain that it does use compilation. Here is the thing: some compilers, along with MSBuild.EXE come with .NET (redistributable) network. And, by the way, it means that Visual Studio is not needed to build projects; a solution with...
2 Aug 2013 by CPallini
We have the very nice article series written by 0x3c0, let's start from the first one: "Beginning Operating System Development, Part One"[^].
26 Sep 2013 by Sergey Alexandrovich Kryukov
When you execute cin>>cptotal and the user enters a valid number, the previous value of cptotal is lost. You can have too different variables for input and accumulation of incremented values. (By the way, many C++ developers will go furious when they see cptotal=cptotal+1;, which looks way...
10 Dec 2013 by Maxim Kartavenkov
Hello,You comparing the pointers but not the strings.First you are not allocating the memory for src and dst variables which may cause crash.To compare strings this way use strcmp or memcmp functions.char src[100],dst[100];strcpy(src , inet_ntoa(ip->ip_src));strcpy(dst ,...
8 Jan 2014 by Jochen Arndt
Windows does not support microsecond time resolution with time stamps. High resolutions are only supported for time spans (e.g. by the performance counter). The Windows Timestamp Project[^] has a very good explanation about the resolutions that can be achieved.
11 Feb 2014 by Sergey Alexandrovich Kryukov
The declaration equivalent to C# declaration show would bestatic string^ helper(Device^ dev);However, that, apparently would not be enough for you. You need to learn how .NET references are work in general, and how are they used with C++/CLI. For that purpose, start reading some C++/CLI and...
13 Mar 2014 by Sergey Alexandrovich Kryukov
Unfortunately, my understanding of you problem is incomplete. First of all, I cannot immediately see how is it related to your previous question about indirect reference of the assembly (which is the non-existing mechanism). By the way, your explanation of your project looks very interesting...
11 Feb 2015 by WoodyMou
Session 1: Setup SoftEther L2TP server on Amazon AWS Ubuntu
30 Oct 2023 by Rick York
You might find this article and the others in the series helpful : Doing UTF-8 in Windows[^]. I don't think you need to encode it per se. Won't just reading and saving text written in Cyrillic be sufficient?
28 Apr 2009 by Member 2516638
C++ wrapper class to compute moving averages
15 Oct 2010 by fantasy1215
Please run the code below.int main(int argc, char* argv[]){ int ii = 20; char tmp[32] = "loveing"; printf("[%d]hello[%s]\n", tmp); //no integer fill the %d format char szData[52] = {0}; sprintf(szData, "[%d]saying [%s]\n",ii);//no string fill the %s format printf("%s", szData); return 0;}The...
9 Sep 2008 by SandeepNK
Sample code is as follows:class TestClass{CCriticalSection m_csTest;void Fun1() { m_csTest.Lock(); Fun2(); MessageBox("In Fun1 critical section."); m_csTest.Unlock();}void Fun2(){ m_csTest.Lock(); MessageBox("In Fun2 critical...
25 Sep 2008 by Christian Flutcher
I know .NET framework and C# well. Recently I started working with C++/CLI which I felt more interesting than C#. Since .NET framework is becoming popular, do you think MFC got obsolete? Are you guys doing any projects in MFC other than...