|
hello all,
1 - is it posiblle to pass ADO Recordset as a parameter from C++ managed code (.Net MC++) to a C++ unmanaged code (the old existing code) function??
how can i do it using the P-Invoce mechanism?
if it's not posibble - how can i call an exisiting C++ unmanaged function that expect me to pass a Recordset parameter???
2- the same question but i need to pass the unmanaged function an
IUnknown* parameter(hold the connection to the DB).
if u can show me an example it will be great
thank's
|
|
|
|
|
Hi, i would like to find out what are the ways to call unmanaged c++ dll's and lib's into c# using visual studio 2005 beta. I have tried many ways like using p-invoke and adding through reference but none of these methods seemed to do it for me. Are there any easier ways to perform this operation using Visual Studio 2005 Beta? I would like to create an application that uses certain dll's and lib's from the ogg vorbis library and implement them into my windows application whereby the GUI would be done using C#. The url for the ogg vorbis codes are as follows. www.vorbis.com. I would really appreciate your kind feedback. Thank you.
|
|
|
|
|
Hi,
I have to use a MFC C++ DLL (unmanaged of course) in a C++ .Net project.
I have problems to do that. I've created a C++ .Net project and includes the MFC DLL.
My problems comes as soon as I call a method (ctor, dtor or method) from the MFC DLL.
I've got this kind of error :
<br />
error LNK2001: unresolved external symbol "public: __thiscall toto::toto(void)" (??0toto@@$$FQAE@XZ)<br />
fatal error LNK1120: 2 unresolved externals<br />
toto is the unmanaged class from the MFC DLL.
I call it in the C++ .Net class like this :
<br />
toto *p;<br />
p = new toto();<br />
(the first line compile but not the second)
Thanks,
Denis (denissohet AT hotmail DOT com
|
|
|
|
|
|
DllImport must be use to import an unmanaged function but I have to import into my C++ .Net code, classes from unmanaged code... And I don't know how to do. I want to do a wrapper but I can't call my unmanaged classes un .Net code. That's my problem in fact.
I've try the DllImport, but I can't call a constructor :s Is it possible to do this ?
Thks
|
|
|
|
|
Sorry for not replying.
I'm not a big fan of MFC, but, I've read that using MFC classes in a .NET CLR project can be problematic. As I recall there is a conflict with a compiler switch that enables runtime type checks in MFC, and this conflicts with the operation of the Common Language Runtime.
Sorry for my previous post, it could just be making things more difficult for you.
There is an article on MSDN Magazine about this problem. I suggest that you search there.
|
|
|
|
|
Hi,
I have to use a MFC C++ DLL (unmanaged of course) in a C++ .Net project.
I have problems to do that. I've created a C++ .Net project and includes the MFC DLL.
My problems comes as soon as I call a method (ctor, dtor or method) from the MFC DLL.
I've got this kind of error :
<br />
error LNK2001: unresolved external symbol "public: __thiscall toto::toto(void)" (??0toto@@$$FQAE@XZ)<br />
fatal error LNK1120: 2 unresolved externals<br />
toto is the unmanaged class from the MFC DLL.
I call it in the C++ .Net class like this :
<br />
toto *p;<br />
p = new toto();<br />
(the first line compile but not the second)
Thanks,
Denis (denissohet AT hotmail DOT com
|
|
|
|
|
Dear friends
I want to add Regional Languages Support in windows XP through code.
The problem is this that what portion (group of files) are needed from winXP CD.
Saifi Hazarvi
Pakistan
|
|
|
|
|
Hi,
i am trying to add a com component in VC (Managed) but the component is not been able to add, i.e. when i try to add, following error is displayed
"Add reference: error adding reference to project"
for additional info, i have a sample sdk that is using the component it is actually developed under VC 6.0 and is using .idl files
Will some body please me how to do this, i will be very thankfull.
Arus.
|
|
|
|
|
You should provide more information along with your inquiry. Anyone responding will have to ask you a number of questions. I assume that you are new to this kind of thing.
If the COM component has a type library, the easiest thing to do is to convert it to a .NET assembly with the utility, TlbImp.exe.
If you don't understand that clearly, then you should read up a little on COM Interop; COM components are unmanaged and you are trying to use it in a managed app.
|
|
|
|
|
(This is a clarification of my prev post - I dont mean to spam but somehow i cannot modify my old post - sorry!)
I have no trouble passing __delegate ptrs to native C functions in DLLs,
however when attempting to pass the __delegate ptr to a native C++ function
in a DLL I get the following runtime exception: An unhandled exception of
type 'System.EntryPointNotFoundException'.
This is confusing b/c if the entry point was not found, I would think I'd
get an unresolved symbol error during linking. Furthermore, I can
successfully pass void, int *, and function pointers, etc to C++ DLL
functions, but this error persists when attempting to pass a __delegate
pointer, which is used for callbacks to managed C++ functions.
Here is the relevant code snippet - the DLL code simply contains stubs of
the functions called here:
using namespace System;
using namespace System::Runtime::InteropServices;
__delegate void testCB();
[DllImport("unmdll.dll")]
void fnunmdll_2(testCB *UpdateProgMeter);
int fnunmdll_0(void);
void fnunmdll_1(int);
__gc class C1
{
public:
static void handleCB()
{
return;
}
};
int _tmain()
{
int k = 9;
//always works (as both C/C++)
fnunmdll_0();
//always works (as both C/C++)
fnunmdll_1(k);
testCB *pCB = new testCB(0, &C1::handleCB);
//if this is a C++ function expecting a function pointer, the
aforementioned error occurs. If this is an extern C function, all is ok!
fnunmdll_2(pCB);
return 0;
}
As crazy as it sounds, I'm beginning to think this is not possible to do this
with native C++ functions.
Thanks in advance, George
|
|
|
|
|
answer: use a .def file in the dll so mangled names are not used. pinvoke doesnt like them i guess.
|
|
|
|
|
I guess you shound use a pin pointer to prevent your delegate from being moving around, and cast the delegate to its native type, void () in this case.
Pin pointer convertion is the only way to cast gc types to native types.
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
I have no trouble using __delegate classes to pass callbacks to native exported C functions, however if I am make the call to an exported function written in C++ and NOT in C, then I get unresolved symbol errors. It’s quite frustrating b/c it seems like it’s just a syntactical thing that shouldn’t be so difficult.
If anyone could point me to a sample where this works, it would be much appreciated! (I don't mind aving to use dllimport to accomplish this).
Thanks in advance, George
//////////Example/////////////
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;
typedef long (_stdcall *CallbackProc) (int lfunctionVal, int lVal, const char *msg);
__delegate long testCB(int, int, const char *);
[DllImport("unmdll.dll")]
extern void __stdcall fnunmdll2(testCB *UpdateProgMeter, int x);
__gc class C1
{
public:
static long handleCB(int x, int y, const char * z)
{
return 0;
}
};
int _tmain()
{
testCB *tmp1 = new testCB(0, &C1::handleCB);
fnunmdll2(tmp1, 0); //if written i C, i am ok. If in C++ it is unresolved! Why?
return 0;
}
|
|
|
|
|
i hav some code in vc# . but i need this in MC++. NET
How to Do this ?
main()
{
string dom = Environment.UserDomainName;
System.DirectoryServices.DirectoryEntry entry = new System.DirectoryServices.DirectoryEntry("LDAP://" + dom);
System.DirectoryServices.DirectorySearcher mySearcher = new System.DirectoryServices.DirectorySearcher(entry);
mySearcher.Filter = ("(objectClass=computer)");
mySearcher.Filter = ("(objectClass=computer)");
foreach(System.DirectoryServices.SearchResult resEnt in mySearcher.FindAll())
{
try
{
System.DirectoryServices.DirectoryEntry de = resEnt.GetDirectoryEntry();
Console.WriteLine("User Name : " + de.Properties["SAMAccountName"].Value.ToString());
}
catch(Exception e)
{
}
}
Console.ReadLine();
}
}
i need to convert this code to MC++ .
How can i do thisd to in MC++ Specially foreach() part.
pls i need experts help.........
i am waiting some reply.....
Sukanta banik
|
|
|
|
|
Replace the . with :: to scope methods in namespaces.
FindAll returns a SearchResultCollection. It has a Count property, so you can do a normal loop and address each item in the collection by index.
SearchResultCollection src = mySearcher.FindAll();
for(int i =0; i < src.Length; ++i)
{
System::DirectoryServices::DirectoryEntry de = src[i].GetDirectoryEntry();
}
This is not tested, but you get the idea.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am making a project under visual .NET studio on 2003 with c++. I have libraries developped in Visual C++. And my problem it is for inclures as libraries in my project. I have file corresponding .lib in libraries.
The error is: LNK2001: 1 to unresolver external
thanks for the information
|
|
|
|
|
This error means you provided a header file for an external method, but not a lib to link to.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yup, make sure you've added the referenced project to to referring project's dependencies.
|
|
|
|
|
I am trying to save files into a specific folder. However if the folder does not exist i get an error saving the file. Ok so i want to create the folder if it does not exist. I thought i would try File::Create("myfoldername") but it just creates a generic file. I looked up Folder::Create() but i am unsure how to use it, the examples only show VB,VBScript. Any suggestions?
|
|
|
|
|
It just takes a path, doesn't it ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
It's not working that way for me, although i thought it would.
|
|
|
|
|
Apparently, you need Directory::CreateDirectory.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi all,
I've got an managed c++ application that needs to display certain information in a graphical display. I've already got things started for the prototype using some basic images. I'm wondering if I could (fairly easily) create some more dynamic images using flash or some other. Basically I'm trying to gauge how easily, if at all possibe, it would be to have some flash images displaying real time data that my managed c++ code creates.
If anyone can point me in the right direction that is all I require.
Thanks in advance.
|
|
|
|
|
The way to display flash is to host IE as a control in a window. Personally, I think it's a bad idea, for starters, if your flash contains UI elements, I'm not sure how their events can be passed from your IE window into your code.
Christian Graus - Microsoft MVP - C++
|
|
|
|