|
I have a MC++ project in VS 2005 – A Windows Forms project. I want to be able to call some native functions from my pool of VC++ 6.0 code, so I’m trying to create a wrapper class to allow me to access these functions. Can anyone offer advice on this?
Right now I’m trying to just get my files together in the same project so I can then create my wrapper class. The steps I’ve taken are:
1 – Created my test project (C++ Windows Form Project)
2 – Added my native file to the project. It’s a simple c++ file that only contains global functions… so I can start out simple.
3 – Changed the “Compile with Common Language Runtime Support” property for my native file to “No Common Language Runtime Support”.
4 – Changed the “Common Language Runtime Support” property for my project to “/clr” (the default was /clr:pure)
5 – Changed the “Use of MFC” property for my project to “Use MFC in a Shared DLL”
6 – Added the text “UNICODE;_UNICODE” to the “Undefine Preprocessor Definitions” property of my native file. Unless I do this step, my project will not build.
This creates a project that will build, but when I attempt to run it I get an assertion in dbgheap.c line 1394. The assertion appears to happen even before the Main method is called.
I’m not sure about the steps I’ve listed above, so it’s possible that I have the process of creating a wrapper class all wrong.
-- greggor
|
|
|
|
|
I am new to CLI (but not to C++). Here is what I dislike about the CLI spec so far:
1) Tries to embrace all "nice" features such that it becomes hardly manageable. This 300-page spec only contains additions/modifications to ANSI C++ spec.
2) Way too complicated. Are the combined access-specifiers like
private protected ...
protected private ...
really necessary?
3) In addition to pointer/reference, it adds handle. Now gcnew returns a handle!
Maybe you can continue on this list...
- It's easier to make than to correct a mistake.
|
|
|
|
|
But what do you expect? It aims for backward compatibility with C++ which is already a complex language, and it creates a binding to .NET which has a very different (inferior ) object model than C++.
Given the constraints, I think they have done a pretty good job.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
there is PictureBox component over the form and I'd like to make it transparent together with form. We can change form opacity but how to do it with PictureBox?
9ine
|
|
|
|
|
Hi,
I request u to kindly ans :
"How to place an edit box and dialog box on a window(SDI)in VC++ dot Net".
Thank you very much.
|
|
|
|
|
Whats wrong with the Threading statements which is no allowing me to create the Thread
System::Threading::Thread *backgroundThread = new System::Threading::Thread (new System::Threading::ThreadStart (SocketConnection,0) );
backgroundThread.Start();
void TCPIP::SocketConnection()
{
}
error C3364: 'System::Threading::ThreadStart' : invalid second argument for delegate constructor; needs to be a pointer to a member function
How it should be rewritten.
-- modified at 8:11 Tuesday 30th May, 2006
|
|
|
|
|
Hi,
as far as i know it should be done like this in C++/CLI:
System::Threading::Thread^ backgroundThread = gcnew System::Threading::Thread (gcnew System::Threading::ThreadStart(this, &TCPIP::SocketConnection));
The "this" pointer is not neccessarily needed but if you pass a nullptr instead, then you'll have to specify a static method.
regards Tobias
|
|
|
|
|
Seems it recetified that issue but i'm getting error
'void TCPIP::SocketConnection(void)' : cannot create a delegate handler for 'System::Threading::ThreadStart' from a non-member function or a member of an unmanaged class
|
|
|
|
|
Put your function in a class:
Create an instance of the object to employ it as a method of that instance, or
make the method static.
|
|
|
|
|
Hi All,
This question might have asked by many person but still im asking
Is it really interesting to code with C++ and .net?
something still resisting me in entering into the world of managed C++
What is ur opinion?
SaRath
"D on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
|
|
|
|
|
I think you have to come out of whatever is resisting you from enterign into manged c++.
You cant get the freedom of mixing both manged and unmanaged in any other language.
Well .net framework class libraries are very very rich, they have wrapped almost everyhting under win32. But still there are cases where we need to mix unmanged code with manged code.
what do you think ...milton kb.
|
|
|
|
|
Hi,
AS you know already we have option called Use Managed Extensions in MFC ActiveX VC++.Net project property to enable the programmers to use managed namespace like System.. etc. Im enabling this option to write Socket Programming and write listner code as like follows,
System::Net::Sockets::TcpListener * pTcpListener;
--------
-------
Is it right/good practice? or is will it create any issues after a while.
|
|
|
|
|
Yes can do it this way. in facat this is one of the feature microsoft provides for VC++ developers. We can mix unmanaged code with managed and the reverse as well.
chers..milton kb
|
|
|
|
|
Anybody please send me a code of searching of a keyword in all files and folders and displaying file names containing that keyword in c++ or in qt 3.3.2
malya
-- modified at 5:35 Monday 29th May, 2006
|
|
|
|
|
use System::IO::Directory::Getfiles or FindFirstfile and Findnextfile recursively for iterating the directories and files.
Then read content of files into an STL string/ System::String^ and call Find() method to chk for the string.
or else you can use the grep utility under the hood.
rgds...Milton KB
|
|
|
|
|
Anybody please send me a code of how to concatenate 2 .wav files with different frequencies in c++ or in qt3.3.2
malya
-- modified at 5:32 Monday 29th May, 2006
|
|
|
|
|
I have a software implemented in java which i have to plugin into MS Word....so it helps in word searching??????
Does MS word provide plugin for java ????? if so hw do i go about doing it???
i have the same software plugged in Acrobat reader, which is in C++???
please tell me which will be more easier to implement????
where can access the source code of MS word API??
ismail
|
|
|
|
|
Hi,
I am trying to convert a managed String^ to a LPCTSTR, but not having much luck. I have tried the following (filename is my String^ variable):
LPCTSTR lpFilename = static_cast<LPCTSTR>(Marshal::StringToHGlobalAnsi(filename).ToPointer());
Marshal::FreeHGlobal(static_cast<IntPtr>(const_cast<void*>(static_cast<const void*>(lpFilename))));
Unfortunately, lpFilename ends up pointing at nonsense. I think that it is pointing to the beginning of the managed string and not the actual string data. I think that I need to offset the pointer to the start of the actual string data since the managed string contains some extra stuff at the beginning?
I had this working under .net 1.1 but everything changed under 2.0. Here is my code under .net 1.1:
const Byte *bp = reinterpret_cast<const Byte*>(filename);
if(bp != 0)
{
unsigned int offset = RuntimeHelpers::OffsetToStringData;
bp += offset;
}
const Char* cFilename = reinterpret_cast<const Char*>(bp);
char* bitmapFilename = static_cast<char*>(Marshal::StringToHGlobalAnsi(cFilename).ToPointer());
Marshal::FreeHGlobal(bitmapFilename);
Any help would be greatly appreciated.
zenzero
|
|
|
|
|
zenzero wrote: LPCTSTR lpFilename = static_cast(Marshal::StringToHGlobalAnsi(filename).ToPointer());
IF you build this with unicode support this won't work as LPCTSTR will point to wide string but StringToHGlobalAnsi return's an ANSI string. If you want unicode string then use StringToHGlobalUni and if you want to build using both ANSI and UNICODE then use StringToHGlobalAuto.
-Saurabh
|
|
|
|
|
Thank you so much.
It's amazing how such a little thing can cause so much trouble!
Regards,
zenzero
|
|
|
|
|
Hi,
I have an ActiveX control and i am using it in my managed C++. What happens is when ever i am compiling my client application i need to crete interops by using Aximp exe and manually copy it to my bin directory is there any way to automate this like post build script. Like when ever i'm compiling my client application interops need to created automatiocally and that sould be copied in the bin directory.
|
|
|
|
|
You can wrap this in a script and set it to be run as a post-build event.
To do that, check out Project->Properties->configuration Properties->Build Events->Pre-Post-Build Event
gmileka
|
|
|
|
|
CString *str = ASCIIEncoding::GetString (resultArray);
I am working in VC++.Net; when i was trying to use the above statement to convert the unsigned character array to string i am getting
error C2352: 'System::Text::ASCIIEncoding::GetString' : illegal call of non-static member function
How to resolve this.
|
|
|
|
|
Create an instance of ASCIIEncoding and then use GetString from that object.
|
|
|
|
|