473,407 Members | 2,314 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,407 software developers and data experts.

I need help with creating a Dll so I can call using COM interop

Hi, I got the following code in a project for creating dll but I'm getting
compiling error. I copied the code (from Main()) from Ineternet but becuase
I don't know how COM interop and how to code to create a dll that I'm sure
the code looks weird to those know how. Can someone tell me how to arrange
the code I have below so it would compile into a dll that I can call later?
Thank you.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.DirectoryServices;

namespace IDsAdminCreateObject
{
static void Main()

{

IDsAdminCreateObject co = new DsAdminCreateObject() as IDsAdminCreateObject;
object nativedsObject = new
DirectoryEntry("LDAP://cn=users,dc=yourdomain,dc=local").NativeObject;
co.Initialize(nativedsObject, null, "user");
object newObject = co.CreateModal(DsAdminCreateObject.GetDeskTopWindo w());

}

[ComImport, Guid("53554A38-F902-11d2-82B9-00C04F68928B"),

InterfaceType(ComInterfaceType.InterfaceIsIUnknown )]

public interface IDsAdminCreateObject

{

/// <summary>
/// Need to initialize before popping up the new object wizard
/// </summary>
/// <param name="ADsContainerObj">initialized dir object Container object
eg: cn=users,DC=domain,dc=local</param>
/// <param name="ADsCopySource">can be null, specifies original object if
you want a copy!</param>

/// <param name="ClassName">contains "User", "group", "contact",
"inetOrgPerson" etc</param>
void Initialize( [MarshalAs(UnmanagedType.IDispatch)] object ADsContainerObj,
[MarshalAs(UnmanagedType.IDispatch), Optional(),
DefaultParameterValue(null)] object ADsCopySource,
[MarshalAs(UnmanagedType.LPWStr)] string ClassName);

/// <summary>
/// Returns native ActiveDirectory object
/// </summary>
/// <param name="hwndParent">handle to parent window, specify 0
(mostly)</param>
[return: MarshalAs(UnmanagedType.IDispatch)]
object CreateModal(IntPtr hwndParent);

}

/// <summary>

/// Have our CLSID_DsAdminCreateObject be imported by .NET
/// </summary>
[ComImport, Guid("E301A009-F901-11d2-82B9-00C04F68928B")]
public class DsAdminCreateObject

{

/// we just needed a pointer to a window, if you run this code within a
Windows Form, you can fetch a handle to it and hand it over to CreateModal!
[DllImport("user32", EntryPoint = "GetDesktopWindow", ExactSpelling = true,
SetLastError = false)]
public static extern IntPtr GetDeskTopWindow();
}

}

--
Thanks.
May 11 '06 #1
0 1135

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

Similar topics

0
by: David Dolheguy | last post by:
I am in desperate need to get help in answering some questions in regards to building a DCOM Server using C#. I need to create a DCOM server using C#.NET, I realise that you first need to create...
5
by: Kedar Agarkar | last post by:
: This is general query seeking opinions about COM+ Development wherein Server is developed in C# and Client accessing that across machines is also C#. Wish to seek experienced words on...
3
by: Gabe Covert | last post by:
I'm a new C# developer, and am developing an application which will utilize a COM library from a third party. I have two following SDK calls from the 3rd-party SDK which I can't get to work under...
2
by: Kirk Marple | last post by:
i'm attempting to interop from C# to a COM DLL, and have found some trouble with a non-standard interface (at bottom of post - followed by my C# version). typically COM methods return an HRESULT...
1
by: Jason Huang | last post by:
Hi, I have no problem in creating or modifying a word document in ASP.Net, using C#. However, I don't know how to export database in SQL 2000 or MSAccess to MSWord, given in the ASP.Net and C#...
17
by: Aaron | last post by:
I've got a doozie of a problem! I and others have been trying to figure this out for too long and I've come to the conclusion that I should probably look for some support.. Ok, I have a COM...
14
by: Christian Kaiser | last post by:
We have a component that has no window. Well, no window in managed code - it uses a DLL which itself uses a window, and this is our problem! When the garbage collector runs and removes our...
2
by: Jmc | last post by:
Hi I need some help with implementing Custom Icon Handlers using c#. I want to show special icons(that I generate) for various file extentions. Lets say for example that I want all bmp images...
1
by: mike11d11 | last post by:
I am using this code to create an email to send automaticaly in my program, the only problem is I get the security warning and I just want the email to go out on its own without the warning. I...
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.