|
I never said it was an operator. I just demonstrated its usage, and you explicited stated it was not an operator and restated my previous post.
Also, I believe the ":" falls under the category of punctuation. Punctuation and operators are lexemes.
Nevertheless, I appreciate your comments and hope we didn't confuse anyone.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hello,
I'm trying to accomplish the following:
A C++ dll project, which uses another dll (which I didn't write).
My project would contain certain unmanaged functions, and then a managed class to encapsulate those functions.
I'm new to C++.NET, and especially to the mixed projects stuff, so after a long unsuccessful journy of trial and error, I've decided to ask here...
What kind of project should I create?
What should I do to create this kind of project?
How and where should I #include "TheDllI'mUsing.h" ?
How do I tell the compiler to treat the "TheDllI'mUsing.h" as a pure unmanaged file?
Anything else I might need to know...?
A link to an article would be good too...
Thanks in advance,
Shy.
|
|
|
|
|
You can create a regular DLL project, and enable /clr compilation.
|
|
|
|
|
Hello,
I have written a program in c++.Now I want to make that program a part of a c# program. So to integrate the programs would I have to conver the unmanged c++ code to managed c++/CLI ?
Thanks in advance
|
|
|
|
|
Revant Jain wrote: I have to conver the unmanged c++ code to managed c++/CLI ?
Maybe. Or you could add mixed mode managed wrapper classes.
led mike
|
|
|
|
|
Hello there fellow programmers,
I'm coding a class library which deals with windows hooks.
It uses the SetWindowsHookEx() API function and provides classes for specific hook types.
So far, the code is written in C#, but I only got as far as low-level hooking (i.e. LLKeyboard, LLMouse hooking).
If I try to use global hooks which are not LL, they of course fail, as they are injected to all processes on the system, and not all processes support managed assemblies.
What I intend to do is write a C++ dll, and use it to communicate with my C# dll.
I know there's a way to compile C++.NET code to pure unmanaged C++ code.
How can I do this?
Is compiling managed C++ as unmanaged going to work with the hooks?
Or perhaps I should write my C++ dll directly in C++, and not through C++.NET code...
Thanks in advance,
Shy.
|
|
|
|
|
It sounds like you could use a "mixed mode" project in VC++. If you search MSDN and here on Code Project Articles you will find much information on "mixed mode" development.
led mike
|
|
|
|
|
shyagam wrote: What I intend to do is write a C++ dll, and use it to communicate with my C# dll
IMO this will cause problems, as DLL are loaded in the process
memory space. Maybe you should consider rewriting your hook in unmanaged C++.
If you cannot do this, you could try to encapsulate your C# dll in an executable
(written in C#). Then you inject your dll written in unmanaged C++, which will be in charge
of running your executable with appropriate parameters. If you need return values
then you should consider encapsulating your C# dll in a COM object (which could also
be written in C#). In this case, your C++ dll would invoke this COM object.
Many options available.
shyagam wrote: I know there's a way to compile C++.NET code to pure unmanaged C++ code.
How can I do this?
You should go to
"Project/Properties/Configuration Properties/General/Common Language Runtime support"
and select "No common language runtime support"
You might need to review other settings depending on what you want to do.
shyagam wrote: Is compiling managed C++ as unmanaged going to work with the hooks?
If your project has the "No common language runtime support" set, it will be a regular
dll, so that should do.
|
|
|
|
|
I've created a Win32 project, and specified in the wizard that I'm writing a dll which exports symbols.
I wrote an unmanaged class to deal with the hooks, and I want to encapsulate it in a managed class using the mixed mode.
So I did Project > Add Class, and created a managed class.
Moreover, I've changed the "Common Language Runtime Support" option to /clr...
Is that wrong?
|
|
|
|
|
If you have written your hook code in unmanaged C++, why do you want to encapsulate it
in a managed class? Do you need to reuse the code somewhere else?
|
|
|
|
|
I want my C# apps to be able to use my C++ exported classes.
I can't do that directly from C#, thus I intend to write a proxy managed C++ class.
|
|
|
|
|
So you seem to be on your way then!
|
|
|
|
|
Thanks for the help.
I'll come back here with future questions I might have.
Thanks again.
|
|
|
|
|
Hi,
Can any one tell me, how can i get the "value name"s and "value data"
of registry key.
Using "RegQueryMultipleValues" , i can know "value data" of multiple
values provided "value Name"s.
Using "RegQueryInfoKey" , i can know no of values a specified key have.
But is there any way to know, all "value names" of specified reg key
Shiva
|
|
|
|
|
You want to do this using .NET APIs ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
No, i want to do with win32 API's only
|
|
|
|
|
OK, then you need to ask in the right forum. 'managed' means this forum is for .NET C++ questions.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi
Could someone point out my code error here.
When I try to compile I get a C2065 OleDbConnection undeclared identifier
error
msg.
Here is my code:
#using <mscorlib.dll>
#using <system.data.dll>
using namespace System;
using namespace System::Data;
using namespace System::Data::OleDb;
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
// The connection
//string cnNwind;
OleDbConnection * conn = new OleDbConnection();
conn->ConnectionString = S "Provider=Microsoft.Jet.OLEBD.4.0; "
S"Data Source=C:\my_databases\taxLots.mdb";
// The connection string
try
{
// Open Database
conn->Open();
Console::WriteLine(S"Connected to database successfully!");
}
catch (OleDbException * pe)
{
Console::Write(S"Error occurred: ");
Console::WriteLine(pe->Message);
}
// Close Connection
if (conn->State != ConnectionState::Closed)
{
conn->Close();
}
Console::WriteLine(S"The database connection is now closed");
return 0;
}
Thanks for any insights.
--
BamaGrad
|
|
|
|
|
Hi;
I finally figured out my problem.
You have to have two references in order for your declared object to
recognized.
Add them to your references folder in the solutions explorer.
They are:
System
System.Data
|
|
|
|
|
Hi All,
I have a vector defined of type vector<char> theString in a function. I need to return this string to the main program, what should be the return type of the function?. I am using "char *" and I have a problem with it. Please let me know what should be the return type and how the function declaration should be. Any help greatly appreciated.
Thanks,
Turbo
char * readline(SOCKET *theSocket)
{
vector<char> theString;
char buffer;
bool bStringEnding = true;
while(bStringEnding)
{
if (recv(*(theSocket), &buffer, 1, 0) == -1)
{
return SERVER_SOCKET_ERROR;
WSACleanup();
}
if(buffer == '\n')
{
bStringEnding = false;
return theString;
}
else
theString.push_back(buffer);
}
return theString;
}
|
|
|
|
|
This is not managed C++, therefore you're asking in the wrong forum.
Why do you need vector<char> ? What's wrong with std::string ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
TurboNext wrote: if (recv(*(theSocket), &buffer, 1, 0) == -1)
Not very efficient way to perform socket communications.
led mike
|
|
|
|
|
Just try
1. vector<char> readline(SOCKET *theSocket); or
2. bool readline(SOCKET *theSocket, vector<char>* pVevChr);
Regards
|
|
|
|
|
Just try
1. vector < char > readline(SOCKET *theSocket); or
2. bool readline(SOCKET *theSocket, vector < char > * pVevChr);
Regards
|
|
|
|
|
We have been using the new override keyword in standard c++ projects.
I have a standard c++ library that includes something like this
class Base
{
virtual bool DoSomething() = 0;
};
class Derived
{
bool DoSomething() override;
};
This compiles fine
This header is included in my managed c++/cli project and because the override keyword has a slightly differnt meaning in CLI I get the following error when compiling the CLI project that includes this file
error C2217: 'override' requires 'virtual'
The simple solution is to change the derived class to be like this
class Derived
{
virtual bool DoSomething() override;
};
Obviously the preprocessor is doing all the includes before the compiler sees this so it has no way of knowing that the code come from a standard c++ project. Is there any other way to resolve this without changing the function declaration?
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|