|
hi all,
i need to call a function in an unmanaged dll say
ERR_CODE MyUnmanagedFn( char** param);
the memory of the param is managed by the dll itself.
the unmanaged code to use this is
char* XX = NULL;
MyUnmanagedFn(&XX); // this is working fine.
this memory is allocated and released sometime later automatically by the dll.
now, i an facing some problem calling this function from Managed c++. the ERR_CODE returned is NULL_PARAMETER. ideally means that the paramter is NULL. what is the equivalent MC++ code for this?
^-^
@|@
- redCat
|
|
|
|
|
Hi alls,
I have short interest of C++/CLI.
Is there somebody who use it in a industrial(comercial) project?
And why we can't use C++/CLI in smart device developpement ?
Thank
|
|
|
|
|
Hello, i've got a really anoying bug that i cant seem to figure out.. The code comes from a 2005 project which needs to be compiled in a 2003 project. The code is as follows:
<br />
#pragma once<br />
<br />
using namespace System;<br />
using namespace System::Runtime::InteropServices;<br />
<br />
namespace CitectAPIManagedDll<br />
{<br />
public __gc struct CitectAPIUnman<br />
{<br />
typedef __gc struct __VTB<br />
{<br />
void (*Open)(CitectAPIUnman*, System::String*, System::String*, System::String*, System::Int32*); <br />
};<br />
<br />
public:<br />
char* id;<br />
static __VTB *vtb; <br />
<br />
[DllImport("CTAPI.dll", <br />
EntryPoint="ctOpen", <br />
CallingConvention=CallingConvention::ThisCall)]<br />
static void Open(CitectAPIUnman*, System::String*, System::String*, System::String*, System::Int32*);<br />
<br />
static void VOpen(CitectAPIUnman* w, System::String* computer, System::String* username, System::String* password, System::Int32* mode)<br />
{<br />
Open(w, computer, username, password, mode);<br />
}<br />
};<br />
<br />
public __gc class CitectAPIWrap<br />
{<br />
public: <br />
CitectAPIWrap()<br />
{<br />
tv = new CitectAPIUnman();<br />
CitectAPIUnman::vtb->Open = CitectAPIUnman::VOpen;<br />
} <br />
<br />
virtual void Open(System::String* computer, System::String* username, System::String* password, System::Int32* mode)<br />
{<br />
CitectAPIUnman::vtb->Open(tv, computer, username, password, mode);<br />
}<br />
<br />
private:<br />
CitectAPIUnman *tv;<br />
};<br />
}<br />
i get the following compile error:
error C2440: '=' : cannot convert from 'void (__clrcall CitectAPIManagedDll::CitectAPIUnman::* )(CitectAPIManagedDll::CitectAPIUnman __gc *,System::String __gc *,System::String __gc *,System::String __gc *,int __gc *)' to 'void (__clrcall *)(CitectAPIManagedDll::CitectAPIUnman __gc *,System::String __gc *,System::String __gc *,System::String __gc *,int __gc *)'
any ideas? this is the first time ive used 2003 to compile this project. your help is greatly appreciated.
|
|
|
|
|
i need to make the conversions to its own function. i was told to use:
void convert_to_f()
void convert_to_c()
as function names.
please help, thank you
#include <iostream.h>
int main()
{
int temp, fahr, cel, f_out, yes, no, choice, c_out;
do
{
cout<<"Please choose one of the following conversions\n";
cout<<"1 - Celcius to Fahrenheit.\n";
cout<<"2 - Fahrenheit to Celcius.\n";
cout<<"Please select at this time: ";
cin>>temp;
switch(temp)
{ case 1:
cout<<"You choose Celcius to Fahrenheit.\n";
cout<<"Please enter the degrees in Celcius: ";
cin>>cel;
f_out = (cel * 1.8) + 32;
cout<<"The degrees converted into Fahrenheit is "<<f_out<<".";
break;
="" case="" 2:
="" cout<<"you="" choose="" fahrenheit="" to="" celcius.\n";
="" cout<<"please="" enter="" the="" degrees="" in="" fahrenheit:="" ";
="" cin="">>fahr;
c_out = (fahr - 32) / 1.8;
cout<<"The degrees converted into Celcius is "<<c_out<<".";
break;
="" default:
="" cout<<"invalid="" choice.";
="" }
="" cout<<"\nwould="" you="" like="" to="" recalculate="" another="" temperature?="" '1'="" for="" yes,="" '0'="" no:="" ";
="" cin="">>choice;
}
while(choice==1);
return 0;
}
|
|
|
|
|
|
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
|
|
|
|