|
hi, i want to make a network application that can be used in a standard Dos
not in the windows that mean it work in Dos Mode, the application is a sniffer so i can recieve and transmit the whole packet. so is there any library that can i use it to achieve my point, and thanks for all
-- modified at 13:44 Friday 19th January, 2007
|
|
|
|
|
When you say DOS application, do you mean a Console application?
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
You want to do this in C++/CLI ? The .NET framework has heaps of libraries, including ones for networking.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
IF you want to use C, you're definatley in the wrong forum
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
This is absolutely the most insane thing I've ever had to do in programming, and I don't even know if it's possible. Please help.
I have an app built with the /clr switch. I have a DLL that contains custom controls, built with the /clr:pure switch because building custom controls with the /clr switch freaks out the IDE designer and I get the message "Failed to load. Custom control will be removed from toolbox."
Now, the custom control in the DLL needs to trigger certain methods of an unmanaged class in the main app. If this was all managed code, I could use delegates. If this was all unmanaged code, I could use function pointers. But how do I pass the address of an unmanaged function to a managed class?
Right now, my unmanaged function signature is like:
public void MyClass::MyFunc(short);
My DLL control managed typedef is:
typedef void MyDllFunc(short); //matches the signature of the unmanaged main app method
My DLL control field is declared:
MyDllFunc *myCall;
In the main app I try to make the assignment:
myControl->myCall = &MyClass::MyFunc;
But I get the compiler error: "Cannot convert 'void(__thiscall MyClass::MyFunc::*)(short)' to 'void(__clrcall *)(short)'".
So what can I do to call an unmanaged function in the main app from a managed function in a DLL?
|
|
|
|
|
There are helper methods to do this. Nish is the person to ask. I'll ping him if I see him online - it's in his ( not yet published ) book.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I dont know if this will help but I used boost events to do something similar. I have a managed template that attaches to the boost event in the unmanaged class and exposes a dot net event with the same arguments. When the boost event fires the dot net event is raised
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
|
I think that will do the trick. I don't know why I didn't think of it, because I already do some similar conversions just within my main app. All of a sudden I'm talking about crossing over between the main app and a DLL and I lost my head. Thanks for pointing out that article!
|
|
|
|
|
I create dynamic event delegates (see code at end of question), which call a common method. When an event is fired, my dynamic method is called and in turn calls the common method.
My problem is that when in the common method the 'this' pointer is meaningless (as if it thinks its a static), so I can't access members of my class. I have a temporary work around where I build in the members to the dynamic method and pass them to the common method! however it still breaks in the debugger and I have to <continue> but gives the desired result.
There is something not right with my dynamic method and if anyone can put me on the right track then that would be greatly appreciated.
Thanks
Peter.
void EventHandler::CreateDynamicEventHandler()
{
System::Type ^ eventClass = m_eventSource->GetTarget()->GetType();
// Get event info and the type of delegate.
array<system::type^>^ args;
EventInfo ^ eventInfo = eventClass->GetEvent(m_eventName);
System::Type ^ tDelegate = eventInfo->EventHandlerType;
MethodInfo^ invoke = tDelegate->GetMethod( "Invoke" );
// The generated delegate will call a standard method (CommonEventHandler)
// to pass the events data onto Jade. Get the method info for that method.
array<system::type^>^ commonArgs = {System::String::typeid, array<system::object^>::typeid};
MethodInfo ^ methodInfo = EventHandler::typeid->GetMethod("CommonEventHandler", commonArgs);
// Create dynamic method
array<system::type^> ^ paramTypes = GetDelegateParameterTypes(tDelegate);
DynamicMethod ^ dynamicMethod = gcnew DynamicMethod("Dyna",
nullptr,
paramTypes,
::EventHandler::typeid);
// Generate method body
ILGenerator ^ ilGen = dynamicMethod->GetILGenerator();
// Create a local variable 'args'
int paramCount = paramTypes->Length;
LocalBuilder ^ localObj = ilGen->DeclareLocal(array<system::object^>::typeid);
// create object array of proper length
ilGen->Emit(OpCodes::Ldc_I4, paramCount);
ilGen->Emit(OpCodes::Newarr, System::Object::typeid);
ilGen->Emit(OpCodes::Stloc_0);
// Now put all arguments in the object array
for (System::Int32 i= 0; i<paramcount; i++)
="" {
="" system::byte="" b="System::Convert::ToByte(i);
" ilgen-="">Emit(OpCodes::Ldloc_0); // Local variable - the array
ilGen->Emit(OpCodes::Ldc_I4, i); // Index into array
ilGen->Emit(OpCodes::Ldarg_S, b); // Value to save is in bth argument to this method
if (paramTypes[i]->IsValueType)
ilGen->Emit(OpCodes::Box, paramTypes[i]); // Box value types
ilGen->Emit(OpCodes::Stelem_Ref, i);
}
// Call common method after pushing parameters
ilGen->Emit(OpCodes::Ldarg_0); // 'this' ptr (required for instance calls)
ilGen->Emit(OpCodes::Ldstr, m_eventName); // Just to help with debugging!
ilGen->Emit(OpCodes::Ldloc_0);
ilGen->EmitCall(OpCodes::Call, methodInfo, nullptr);
ilGen->Emit(OpCodes::Ret);
// Create delegate (Also completes dynamic method build)
System::Delegate ^ del = dynamicMethod->CreateDelegate(tDelegate);
// Add delegate to event's invocation list
MethodInfo ^ addHandler = eventInfo->GetAddMethod();
array<system::object^> ^ addHandlerArgs = {del};
addHandler->Invoke(m_eventSource->GetTarget(), addHandlerArgs);
}
|
|
|
|
|
i, i am newbie in C++/CLI WinForms.
I am trying to send text the textBox1 of Form1 at label1 in Form2 but i can send text of textbox2 of Form2 at label2 in Form1.
The #include "Form1.h" in form2 give problems.
I think in use a ref class.
--[ controlWindows.h ]--
namespace ControlWindows
{
using namespace System;
using namespace System::Windows::Forms;
ref class CWindows
{
static Form ^WindowsX2;
//static Form2 ^WindowsX22; // ERROR
static bool X2Status = false;
public:
// FORM2
static void ShowFormX2();
static void CloseFormX2();
static void ChangeCaptionX2();
static void MngVentanaX2(Object ^Obj);
};
}
-- EOF controlWindows.h --
--[ ControlWindows.cpp ]--
#include "controlWindows.h"
using namespace ControlWindows;
#include "Form1.h"
#include "Form2.h"
using namespace formToform;
void CWindows::ShowFormX2()
{
if ( X2Status == false)
{
WindowsX2 = gcnew Form2;
WindowsX2->Show();
X2Status = true;
}
}
void CWindows::CloseFormX2()
{
// cierra la ventana
WindowsX2->Close();
Estado = false;
}
void CWindows::ChangeCaptionX2()
{
WindowsX2->Text = L"Nuevo Caption";
WindowsX2->Update();
}
void CWindows::MngVentanaX2(Object ^Obj)
{
// WindowsX2->textBox1->Text = L"ASDASD"; // i dont get it
WindowsX2->Text = Obj->ToString();
// WindowsX2->textBox1->Text = Obj->ToString();
}
-- EOF controlWindows.cpp --
The Form2 has textBox1 but "static Form ^WindowsX2;" i get only access to form virgin, i dont have access to real form2 object
any idea?
thank
|
|
|
|
|
To communicate in both directios, you should use delegates, or pass a reference to your form1 in to form2.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
???????
I do not understand what you say to me.
|
|
|
|
|
form2 needs a copy of form1, a pointer, to call it's methods. Or, you can use delegates. (clue: when people use a word you don't know, google will define it for you )
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi,
An application written in C#-VS2005 needs to use a class exported in a VC6Dll.
I have googled around a bit about Data Marshalling using P/Invoke. But all I could find is information on how to use the exported functions from a dll OR a struct from a dll.
I could not find any info on how to use the (exported,unmanaged) class of the dll in my C# App.
Any help or link woud be helpful.
Thanks and Regards,
Arti Gujare
|
|
|
|
|
Don't cross post especially don't cross post into a C++ forum with a C# question.
led mike
|
|
|
|
|
Apologies.
This Mixed Mode coding makes me confused sometimes. :
|
|
|
|
|
Hi all...
I am working with visual studio 2005.In my application ,i need to transfer dataset content to local database table.I am using MS Access .Please help me...
Thanks
vinod
|
|
|
|
|
Have you looked at the scores of Database articles here on CodeProject?
led mike
|
|
|
|
|
When using a Managed C++ Wrapper to expose methods to C# and VB.NET I get cannot create reference to this object when I transfer my compiled application to another machine. I am using C# and VB.NET by making a reference to it, and (Using or Import...), I am able to compile on a machine using VS-2005 CLI C++ and make a DLL. On the same machine I can reference this DLL, and utilize its exposed methods. This works all the time on the same machine that I compiled the CLI C++ DLL on, but when I copy the C# or VB source code and DLL to another machine, I have to re-run the Managed C++ Compile from source code in order to properly reference the DLL. What am I missing if I want to compile and distribute my VB or C# Application with this DLL? What is the compiler doing that I am not when I reference the DLL? Should I attempt to Sign and import it into the GAC or? What is the proper way of performing this?
|
|
|
|
|
Your app probably requires the redistributable for C++, and you also need to make sure you distribute the manifest file
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Given a Borland OWL application, I am curious if it is possible to display C# dialogs. I know OWL will allow calls into MFC DLLs. And I have already done work in an MFC application to display C# dialogs.
So it seems reasonable for OWL to call the MFC DLL which will call the C# DLL.
I am wondering if it will require the MFC DLL to be a regular DLL (derived from CWinApp), or if an extension DLL will also work.
At this time, I do not actually have a Borland OWL application, otherwise I would just try it out for myself. I am curious for a future possibility requiring this ability. I was thinking the OWL application's menu item can call into the MFC DLL, which will be a pass through to a C# DLL(s) containing various C# dialogs.
Thanks for any insight and help.
|
|
|
|
|
|
Oops. Sorry. In the past (meaning several months ago), I've seen this board used for MFC->Managed and MFC->.NET questions, whereas the C# board has been more focused directly on C# questions.
|
|
|
|
|
hi friends
i am new in c++
I have one file enc.cpp
i dnt know how to run it.
plz tell me how to run project in c++ .net
thanks in advance.
khan
|
|
|
|