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.Collecti ons.Generic;
using System.Text;
using System.Runtime. InteropServices ;
using System.Director yServices;
namespace IDsAdminCreateO bject
{
static void Main()
{
IDsAdminCreateO bject co = new DsAdminCreateOb ject() as IDsAdminCreateO bject;
object nativedsObject = new
DirectoryEntry( "LDAP://cn=users,dc=you rdomain,dc=loca l").NativeObjec t;
co.Initialize(n ativedsObject, null, "user");
object newObject = co.CreateModal( DsAdminCreateOb ject.GetDeskTop Window());
}
[ComImport, Guid("53554A38-F902-11d2-82B9-00C04F68928B"),
InterfaceType(C omInterfaceType .InterfaceIsIUn known)]
public interface IDsAdminCreateO bject
{
/// <summary>
/// Need to initialize before popping up the new object wizard
/// </summary>
/// <param name="ADsContai nerObj">initial ized dir object Container object
eg: cn=users,DC=dom ain,dc=local</param>
/// <param name="ADsCopySo urce">can be null, specifies original object if
you want a copy!</param>
/// <param name="ClassName ">contains "User", "group", "contact",
"inetOrgPer son" etc</param>
void Initialize( [MarshalAs(Unman agedType.IDispa tch)] object ADsContainerObj ,
[MarshalAs(Unman agedType.IDispa tch), Optional(),
DefaultParamete rValue(null)] object ADsCopySource,
[MarshalAs(Unman agedType.LPWStr )] string ClassName);
/// <summary>
/// Returns native ActiveDirectory object
/// </summary>
/// <param name="hwndParen t">handle to parent window, specify 0
(mostly)</param>
[return: MarshalAs(Unman agedType.IDispa tch)]
object CreateModal(Int Ptr hwndParent);
}
/// <summary>
/// Have our CLSID_DsAdminCr eateObject be imported by .NET
/// </summary>
[ComImport, Guid("E301A009-F901-11d2-82B9-00C04F68928B")]
public class DsAdminCreateOb ject
{
/// 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("user 32", EntryPoint = "GetDesktopWind ow", ExactSpelling = true,
SetLastError = false)]
public static extern IntPtr GetDeskTopWindo w();
}
}
--
Thanks. 0 1147 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 the managed code, attach interfaces and use the CCW
command line tool to add a COM wrapper to the assembly.
The server will be communicating with a DCOM client which I didn't
write, but I have all the documentation on what interfaces and...
|
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 issues of COM-.NET interop that is
playing major decisive role on both sides and is making decisions
complicated only based upon theory.
|
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 C#:
SDK declaration:
VARIANT_BOOL ReadMemory(unsigned char* Data, long DataSize);
tlbimp result:
|
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 or just void. for some reason, this
one is returning a string (char *) or in other interfaces is returning a
struct.
i'm pretty familiar with interop for normal params and using IntPtr
marshalling to structures, but i'm not sure how this works...
|
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# environment.
I surfed the net and found some articles about interop ASP.Net with the
MSWord.
But I didn't find resource regarding using the MSWord as the ASP.Net C#
report.
| |
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 component written in C++ (I don't have the source just the
binary) and am referencing it from VB. I would say about 99% of the
functionality exposed by this COM component works fine from vb .net but I am
having a problem calling a method which has a...
|
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 component (created
dynamically by, say, a button click, and then not referenced any more), the
GC runs in a different thread, which prohibits the DLL to destroy its
window, resulting in a GPF when the WndProc of that window is called - the
code is gone...
|
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 to have the image as an
icon.
I understand that I need to implement the a number of interfaces,
IUnknown, IPersistFile and IExtractIcon (right?).
But how do I actually do that using c#?
|
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 heard this
can only be done by creating your own Com add-in but I really dont
know how to do that and am pretty new to the programming world. Any
help with my code below would be greatly appreciated, oh yeh I'm using
outlook 2003 pro.
Dim oOutL...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |