473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Writing an ActiveX control for cs

I have an dll written in c++ but I cannot use it directly in c#
because it has some complex structures that is not supported by
invocation system.

Which solution is proper writing an ActiveX component or using some
unsafe code?

In second dllimport has very poor performance(I use it for exported
function that has not have complex structure argument).Loading dll
takes long time.How can I use it c#?
Nov 16 '05 #1
5 1759

"BveB" <bb****@st.cs.deu.edu.tr> wrote in message
news:ac**************************@posting.google.c om...
I have an dll written in c++ but I cannot use it directly in c#
because it has some complex structures that is not supported by
invocation system.

Which solution is proper writing an ActiveX component or using some
unsafe code?
**** Write a managed wrapper for your C++ dll using ME C++ (visual C++ 7.x).
In second dllimport has very poor performance(I use it for exported
function that has not have complex structure argument).Loading dll
takes long time.How can I use it c#?


*** Could you be more specific?
Loading a dll is fast and only happens once (at the first function call ),
or do you mean each function call is slow?
Did you measure the call overhead? Do you have some timing figures?

Willy.

Nov 16 '05 #2

"BveB" <bb****@st.cs.deu.edu.tr> wrote in message
news:ac**************************@posting.google.c om...
I have an dll written in c++ but I cannot use it directly in c#
because it has some complex structures that is not supported by
invocation system.

Which solution is proper writing an ActiveX component or using some
unsafe code?
**** Write a managed wrapper for your C++ dll using ME C++ (visual C++ 7.x).
In second dllimport has very poor performance(I use it for exported
function that has not have complex structure argument).Loading dll
takes long time.How can I use it c#?


*** Could you be more specific?
Loading a dll is fast and only happens once (at the first function call ),
or do you mean each function call is slow?
Did you measure the call overhead? Do you have some timing figures?

Willy.

Nov 16 '05 #3
Hi
with the ActiveX control , you can still use the DllImport and for the
complex structure you can write the unsafe blocks and use the marshaling
class to marshal data to the unmanaged DLL.
About how to use the dll import ( although I think you should have already
done that )
Add the dll import attribute any where in your code , put the name of the
function you are to use in the entry point .
[DllImport("winmm.dll", EntryPoint="PlaySound")]
Then define the function as external
public static extern bool PlaySound_DllImport(string
pszSound,IntPtr hmod ,int fdwSound );
Define the input and output parameters of the function in your code ( in
your case it could be more than that , use whatever type into unsafe block )
bool result;
System.IntPtr resourceHandle = System.IntPtr.Zero;

Then simply call the function
result = PlaySound_DllImport("c:\\1.wav",resourceHandle,0);

hope that helps.
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #4
Hi
with the ActiveX control , you can still use the DllImport and for the
complex structure you can write the unsafe blocks and use the marshaling
class to marshal data to the unmanaged DLL.
About how to use the dll import ( although I think you should have already
done that )
Add the dll import attribute any where in your code , put the name of the
function you are to use in the entry point .
[DllImport("winmm.dll", EntryPoint="PlaySound")]
Then define the function as external
public static extern bool PlaySound_DllImport(string
pszSound,IntPtr hmod ,int fdwSound );
Define the input and output parameters of the function in your code ( in
your case it could be more than that , use whatever type into unsafe block )
bool result;
System.IntPtr resourceHandle = System.IntPtr.Zero;

Then simply call the function
result = PlaySound_DllImport("c:\\1.wav",resourceHandle,0);

hope that helps.
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #5
No I dont have any timing figures but i can see it with my eyes
program suspends a little when I call a dll function
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: wang xiaoyu | last post by:
Hello: i want use activex in wxpython program,but when i use MakeActiveXClass an exception occurs. this is my source code dealing the DICOM ocx.I must note that in this program "hwtxcontrol" is...
3
by: adam | last post by:
hi is it possible to write activeX controls in C# and if so any suggestions of links to sample code would be appreciated? thanks Adam
0
by: Gazelle | last post by:
I have a dilemma, that I am hopping I can find some help with. He is the back story so everyone sort of understands what it is that I am trying to accomplish. My problem: I have multiple...
3
by: Jeffery Franzen | last post by:
Anyone know where the documentation is regarding Activex controls in asp web forms? I'm using VS.NET 2002 enterprise and am trying to use Activex controls in vb.net web form app. I do the add...
7
by: Jarod_24 | last post by:
I just downloaded a activex control that was written in C# and tried to view it on my PDA's Internet Explorer. At my regular PC it displayed just fine, but nothing showed up on the pda. Do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.