|
Hi,
I am trying to use the getprocessesbyname manged extension from the system:diagnosics system.dll
from .NET with C/C++
Do any one knows away to get for a speacific process name how many process currently running and then use it in an unmanage project.
I don't want to define it with complier \clr and then use #pragm unmange and mange,tried it already and the rest of the project didn't compile.
And the only way I had luck of using it by creating a manage project and
using this code:
[C++]
#using <mscorlib.dll>
#using <system.dll>
using namespace System;
using namespace System::Diagnostics;
int main()
{
//process running eyal.exe
Process* localByName[] = Process::GetProcessesByName(S"eyal");
}
I just want to be able to run only one program eyal.exe ,and if try to run more then one will have a message and then terminate the second process.
Thanks
Will be glad to get any help.
|
|
|
|
|
I am new to the Managed C++,I have created a namespace "N" with one "Cl" class in that name space.
Now I want to use this "Cl" as a data memeber in a unmanaged C++ class.
the syntax i have followed in Unmanaged c++ class header is as follows..
class Unmanged
{
public:
Cl *m_Managed;
};
The reported error is..
error C3265: cannot declare a managed 'm_Managed' in an unmanaged 'Unmanaged'
Please help in solving this is very urget for my assignement.. Thanks.
|
|
|
|
|
Are both of these classes in the same application? Is the unmanaged class a COM object?
At any rate, when you transfer data to and from managed and unmanaged types or call functions again from managed to unmanaged, or from unmanaged to managed classes or objects, the Interop marshaler takes care of some operations (invisibly from the programmer's point of view). Generally, this involves some data transfer and the marshaler tries to convert defined types to their compatible types in the other domain. The marshaler, because it deals with so many different and disparate types has a well-designed behavior. User-defined types are the most difficult to deal with and sometimes it is necessary to write a custom marshaler to enable the Interop to work properly.
There is lots of information over at the MSDN site.
And, in all honesty, I am not that experienced in this area, but, it is common to experience problems with Interop.
I have been reading: "NET and COM: The Complete Interoperability Guide", by Adam Nathan, and I would highly recommend it as a source of 'official' Interop intel.
A simple suggestion, though: use the same types for your data in both managed and unmanaged classes, and re-write your functions so that they accept those data members, rather than the class.
|
|
|
|
|
|
Help me,please.
Thanks a lot.;P
|
|
|
|
|
What do you want to do ? Why are you asking in a managed C++ forum ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Help me,please.
Thanks a lot.;P
|
|
|
|
|
Hai,
In my application i want to rotate the Polygons i have drawn in a specifeid angle without using the RotateTrasnfom(bcoz a lot of other object are in my drawings).
Nanyone have any idea about it?
Thnaks in Advance
|
|
|
|
|
Don't you just rotate, draw, then rotate back ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hi! I'm trying to write a grayscale 8-bit BMP file header (without using special classes and without specifying color table). For example, I want to know the way that Windows's mspaint.exe writes the grayscale-headers. I have learned the specifications for writing a header for RGB (24 bit) bitmap, but I couldn't change the values for the grayscale one. Maybe there are several specifications and I use the wrong one (i.e it is valid only for RGB bitmaps). Could anyone help me with this problem?
Thanks in advance!
|
|
|
|
|
Create two simple 1*1 black and 1*1 white bmps and see the header in some hex editor!
It will work!
Kamyar Souri
Booria CAD/CAM Systems
www.booria.com
|
|
|
|
|
i'm quite new to managed c++, so sorry for the question, but: can i have an unmanaged function within a managed class? specifically, i'd like to declare a variable (if i can have it as a member, even better) using a __declspec , while keeping my class managed.
Any help would be much appreciated.
there are no facts, only interpretations
|
|
|
|
|
I have seen examples of C++ unmanaged classes in extension DLLs, wrapped successfully with managed C++ classes, also in their own DLL, so that the managed classes can be called from C#. However, every example I have seen uses an unmanaged class that does not use any MFC. For example, I cannot find a single example (and have so far failed to create one myself) of an unmanaged C++ class that has some functions with CString arguments and/or return values, wrapped by a managed C++ class in a DLL, callable from C#. If anyone has such an example, I'd be forever grateful to receive it. When I try it, IJDW (it just doesn't work). I can get everything to compile file, but when I try to pass a string from the C# program down through the MC++ DLL to the unmanaged C++ DLL, I get an exception down there at the bottom saying that the object reference is not set to an instance of an object, even though I can see that the passed in string is just fine.
Thanks for any assistance.
|
|
|
|
|
Unfortunately, I don't use MFC in my coding projects, so my advice will be somewhat incomplete. We get this problem alot in Interop operations when passing data (often strings or structs) to native pre-.NET C++ functions in compiled DLLs.
The basic problem is the way the Interop marshaler processes the data; the default behavior has limited applicability with user-defined data structures. This is particularly a problem in COM, as many of the data structures are defined as types that have no compatible type in .NET.
The solution in .NET is to use attributes to control the marshaling behavior of the Interop when the default behavior is inappropriate, as in this case.
I suggest that you review the MarshalAs(UnmanagedType) attribute documentation over at MSDN. In all honesty, I don't what the correct usage would be, but, hopefully you won't have to write a custom marshal routine (because it's such a pain in the ass).
Try reading this: Deafult Behavior for Strings:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondefaultmarshalingforstrings.asp[^]
..or, this, the MarshalAs(UnmanagedType) Enumeration:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemruntimeinteropservicesunmanagedtypeclasstopic.asp[^]
|
|
|
|
|
I declared a few strings for a managed class:
public __gc class class1
{
public:
// function
String *string1;
String *string2;
};
Then in the contructor, I allocate memory for those string:
class1::class1()
{
string1 = new String("");
string2 = new String("");
}
But when I use them, the program is not stable, sometimes it just throw an exception on those string. I think I need to allocate enough memory for those string. How do I allocate memory for a string with specify length?
Thanks
|
|
|
|
|
I created a c++ object and exported the funtion I wanted to use with dllexport. Then created a managed wrapper that linked with my unmanaged
code. I used c# Windows application that made use of the managed wrapper.
All this works fine. Yipee
Now i am trying to export the entire c++ object. SO i have
//------------------------------------------------------
class __declspec(dllexport) Sum
{
public:
Sum();
~Sum();
public:
double Add( double num1, double num2 );
};
//------------------------------------------------------
Is it possible to export the entire class.
Now the MC++ was
//------------------------------------------------------
extern "C"
{
double Add( double num1, double num2 );
}
//--namespace stuff and other declaration
__gc class Class1
public: double DoAdd( double n1, double n2 )
{
return Add( n1, n2 );
}
//------------------------------------------------------
My question is what do I replace the extern "C" part with now and assuming that I dont have the source code for the c++ code, just the dll
and lib files.
|
|
|
|
|
Hi everybody, I'm a student, and I'm triying to create the tree command like int DOS, to print all the directories and files of my hard disk, but I can't .I must use "findfirst" and "findnext" function in Turbo C++ (3.0).
Please, help me!!! doh:
|
|
|
|
|
Well, I think I'd be right in saying that Turbo C++ does not support managed C++. You should find a forum that supports your compiler ( although from memory, firdfirst and findnext are Windows API functions, which means it shouldn't matter ). Your solution will be recursive, it will call itself whenever it finds a folder to move into.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I've created MFC Application using Visual Studio 2003, then change the project settings
to use Managed Extensions as follows:
1. Configuration Properties->General->use Managed Extension : Yes
2. C/C++->General->Debug Information Format : Program Database (/Zi)
3. C/C++->Code Generation->Enable Minimal Build : No
4. C/C++->Basic Run-Time Check : Default
then in the CMyClassDlg.cpp did the following:
#using <mscorlib.dll>
#using <system.dll>
using namespace System;
#using <system.xml.dll>
#using <system.data.dll>
and in the OnInitDialog() did :
XmlDocument *xmlDoc = new XmlDocument();
//Just this to try
and compile this error message appeared:
(105): error C3828: 'System::Xml::XmlDocument': placement arguments not allowed while creating instances of managed classes
I dont know why this error generated ,though I did the same thing in my ISAPI Filter DLL project and used XmlDocument
and SqlClient effectively.
why this happening in MFC application .
Any Idea? Regards.
|
|
|
|
|
this the directive the check box for using < as HTML was not checked
#using <mscorlib.dll>
#using <System.dll>
using namespace System;
#using <System.Xml.dll>
#using <System.Data.dll>
|
|
|
|
|
Hi!
I need to get the names and parameters of the functions out of an compiled dll.
thanks in advance
thomas
|
|
|
|
|
You should be able to read the library with Visual Studio.NET or the IL Disassembler. (I'm assuming that it was compiled with a .NET compiler.)
|
|
|
|
|
I've asked this question a while back and couldn't seem to get a straight answer. I want to make a MFC project using managed extensions. If I have a CFormView based form as my main window, can I add a windows form to my project and show it modal/modeless from an event in my main form (like pressing a button)? I've added a windows form to my project, but now I don't know how to make it display. Does anyone have any suggestions? Any help is appreciated. Thanks
while(true)
{
TryToLearn("C++,MFC");
}
My articles[^]
bdiamond
|
|
|
|
|
I've migrated an existing function from a mex file (previously used with Matlab) into a .c file and incorporated it into an existing MFC application (I compile it with the rest of the files, not as a separate library).
For some reason, that specific function runs much slower than it does when I run the similar mex version from Matlab. It has 7 nested 'for' loops which access different locations in an ~10300 long float array.
Is there a way to optimize the running time?
|
|
|
|
|
maybe if you put the code here i can help you, anyway 7 nested loops sounds very huge, i think that mathlab does a optimization maybe or a prebuffer...
|
|
|
|