Click here to Skip to main content
15,885,278 members
Home / Discussions / C#
   

C#

 
AnswerRe: Move a Webbrowser to a new window? Pin
Stephane Rodriguez.19-Feb-03 11:07
Stephane Rodriguez.19-Feb-03 11:07 
GeneralRe: Move a Webbrowser to a new window? Pin
Bog20-Feb-03 6:55
Bog20-Feb-03 6:55 
GeneralSearching a C# String Pin
vlusardi19-Feb-03 7:29
vlusardi19-Feb-03 7:29 
GeneralRe: Searching a C# String Pin
Chris Austin19-Feb-03 8:19
Chris Austin19-Feb-03 8:19 
GeneralBefore Delete File Event Pin
nissiml19-Feb-03 7:11
nissiml19-Feb-03 7:11 
GeneralRe: Before Delete File Event Pin
Chris Austin20-Feb-03 3:51
Chris Austin20-Feb-03 3:51 
GeneralMaking GetObject work for LDAP Pin
Atul Kale19-Feb-03 7:00
Atul Kale19-Feb-03 7:00 
GeneralRe: Making GetObject work for LDAP Pin
Richard Deeming20-Feb-03 0:03
mveRichard Deeming20-Feb-03 0:03 
You really should be using System.DirectoryServices for this, and only resorting to the ADSI library as a last resort.

The Activator.GetObject is not related to the VB GetObject function. To replace the VB functionality, you can either use the Microsoft.VisualBasic.Interaction.GetObject function, or use a combination of the BindToMoniker and GetActiveObject functions from the System.Runtime.InteropServices.Marshal class.
using System;
using System.Runtime.InteropServices;
 
public class ComUtils
{
    public static object GetObjectFromClass(string className)
    {
        object ret = Marshal.GetActiveObject(className);
        
        if (null == ret)
        {
            // NB: Not sure if this is needed,
            // but the GetActiveObject functions should
            // only return an existing object, not
            // create a new instance.
            Type t = Type.GetTypeFromProgID(className);
            ret = Activator.CreateInstance(t);
        }
        
        return ret;
    }
    
    public static object GetObject(string pathName)
    {
        return Marshal.BindToMoniker(pathName);
    }
    
    public static object GetObject(string pathName, string className)
    {
        if (null == pathName || 0 == pathName.Length)
        {
            return GetObjectFromClass(className);
        }
        else if (null == className || 0 == className.Length)
        {
            return Marshal.BindToMoniker(pathName);
        }
        else
        {
            // Class and path specified
            object ret = GetObjectFromClass(className);
            
            UCOMIPersistFile pf = (UCOMIPersistFile)ret;
            pf.Load(pathName, 0);
            
            return pf;
        }
    }
}



"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
GeneralRe: Making GetObject work for LDAP Pin
Atul Kale20-Feb-03 20:23
Atul Kale20-Feb-03 20:23 
GeneralDisk Quotas C# Pin
daaaaave19-Feb-03 6:32
daaaaave19-Feb-03 6:32 
GeneralCrystal Reports newcomer and Visual Studio Pin
Braulio Dez19-Feb-03 6:07
Braulio Dez19-Feb-03 6:07 
QuestionHow can I save GDI drawings on a form to jpg or gif Files Pin
mosessaur19-Feb-03 5:35
mosessaur19-Feb-03 5:35 
AnswerRe: How can I save GDI drawings on a form to jpg or gif Files Pin
Aboelkhair20-Feb-03 12:45
Aboelkhair20-Feb-03 12:45 
GeneralHelp Please: ComboBox Control in WinForm Datagrid Control Pin
DionChen19-Feb-03 5:08
DionChen19-Feb-03 5:08 
Generalc# and win CE Pin
Roger Alsing19-Feb-03 2:55
Roger Alsing19-Feb-03 2:55 
GeneralRe: c# and win CE Pin
Stephane Rodriguez.19-Feb-03 3:10
Stephane Rodriguez.19-Feb-03 3:10 
GeneralRe: c# and win CE Pin
Roger Alsing19-Feb-03 23:09
Roger Alsing19-Feb-03 23:09 
GeneralRe: c# and win CE Pin
Stephane Rodriguez.19-Feb-03 23:18
Stephane Rodriguez.19-Feb-03 23:18 
GeneralRe: c# and win CE Pin
sunnytyra7-Oct-09 17:52
sunnytyra7-Oct-09 17:52 
GeneralRe: c# and win CE Pin
TigerNinja_20-Feb-03 4:57
TigerNinja_20-Feb-03 4:57 
GeneralRe: c# and win CE Pin
Furty20-Feb-03 17:45
Furty20-Feb-03 17:45 
GeneralC# Call VC DLL Pin
aoyee19-Feb-03 1:31
aoyee19-Feb-03 1:31 
GeneralRe: C# Call VC DLL Pin
Stephane Rodriguez.19-Feb-03 3:00
Stephane Rodriguez.19-Feb-03 3:00 
GeneralRe: C# Call VC DLL Pin
Anonymous19-Feb-03 11:41
Anonymous19-Feb-03 11:41 
QuestionWhy xml line highlighted yellow in IDE? Pin
Member 9618-Feb-03 16:20
Member 9618-Feb-03 16:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.