|
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
|
|
|
|
|
Try surrounding the code with the managed/unmanaged pragmas.
|
|
|
|
|
Josh,
The native code also needs override paired with virtual also! Here is an example taken out of Microsoft's documentation (How to: Declare Override Specifiers in Native Compilations ):
#include <stdio.h>
__interface I1 {
virtual void f();
};
class X : public I1 {
public:
virtual void f() override {}
virtual void g() override {}
};
|
|
|
|
|
George L. Jackson wrote: The native code also needs override paired with virtual also! Here is an example taken out of Microsofts documentation:
That is what I thought. The code in question was written by someone else and committed to source control yesterday. It does appear to compile and run without the virtual keyword. I think Ill have a word with him.
Interestingly the prama does not resolve the issue which would suggest that the /CLI option makes the compiler produce this error.
Thanks again for your help
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
|
Thanks again for all your help mate
We use the override keyword in our nonmanaged code to catch cases where people override a method thats not virtual
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
Hi,
I am trying to copy data from a structure
<br />
typedef struct OctetString {<br />
unsigned int length;<br />
unsigned char *value;<br />
} OctetString;<br />
I have only managed to copy the value using a for-loop and an ArrayList
<br />
OctetString* data;<br />
ArrayList^ bits = gcnew ArrayList();<br />
for(unsigned int i=0;i<data->length;i++)<br />
{<br />
bits->Add((char)*data->value);<br />
data->value++;<br />
}<br />
My question is: Is there a better way to copy the data into the ArrayList, and is
there a more suitable structure than a ArryList to handle binary data of different lengths?
/krissi
|
|
|
|