CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2007
    Posts
    8

    Referencing dll from another program

    Hello,

    I'm trying to reference a dll created by another program. I don't think I can distribute the dll(s) with my program, so I need to be able to find them in their native directories. I have the following function right now:

    Code:
    public static void Activate_Plugins(List<string> pluginlist, Settings.SettingsFile CurrentSettings)
                {
                    string path = "";
    
                    if (System.Environment.Is64BitOperatingSystem == true) { path = CurrentSettings.BOSSPath + "\\API\\boss64.dll"; }
                    else { path = CurrentSettings.BOSSPath + "\\API\\boss32.dll"; }
    
                    if (File.Exists(path))
                    {
                        Assembly.LoadFile(path);
                    }
                }
    How do I now reference functions in the dll?

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Referencing dll from another program

    What kind of dlls are they? Are they .net assemblies or native Win32(64) dlls?

  3. #3
    Join Date
    May 2007
    Posts
    8

    Re: Referencing dll from another program

    I believe they are native dlls. I'm completely new to using dlls in C#; I was successfully able to integrate a .NET assembly and call its function just by adding a reference to the dll in solution explorer, but in that case I was licensed to redistribute the dll which is not the case here.

    The following are excerpts from the API's documentation. Do I need to somehow define the data types from the API in my own program? All I need is to call the functions below.

    The API uses character strings and integers for information input/output.

    All strings are unsigned 8-bit character strings (uint8_t*) encoded in UTF-8 and are null-terminated.
    All codes are unsigned 32-bit integers (uint32_t).
    All array sizes and positions use the unsigned data type size_t.
    File paths are case-sensitive if the underlying file system is case-sensitive.
    The API also introduces three new structures:
    typedef struct _boss_db_int * boss_db;
    The boss_db structure abstracts the definition of BOSS's internal state while still providing type safety across the API.
    typedef struct {
    uint32_t id;
    const uint8_t * name;
    } BashTag;
    The BashTag structure gives the Unique Identifier (UID) for each Bash Tag and the corresponding Bash Tag name.
    typedef struct {
    uint32_t type;
    const uint8_t * message;
    } BossMessage;
    The BossMessage structure gives the type of a message and the message string itself.

    ...

    BOSS API provides the functions listed below to clients. Where a function returns a uint32_t value, this is the function's return code.
    ...
    Load - Loads the masterlist and userlist from the paths specified, for the game specified when the given database was created. Can be called multiple times. If an error is encountered, the database remains unchanged. Calling this function for a database that has already been loaded will reload it, freeing any memory allocated by functions that take a boss_db argument, and scanning the data directory specified when the database was created for newly added plugins.
    uint32_t Load (boss_db db, const uint8_t * masterlistPath, const uint8_t * userlistPath);
    db - The database the function acts on.
    masterlistPath - A string containing the relative or absolute path to the masterlist file that should be loaded.
    userlistPath - A string containing the relative or absolute path to the userlist file that should be loaded. If NULL, no userlist will be loaded.
    ...
    These functions require a database to be created, but do not require Load to have been called. Plugins should be passed with their unghosted filenames, whether or not they are currently ghosted.

    GetActivePlugins - Returns the contents of plugins.txt.
    uint32_t GetActivePlugins (boss_db db, uint8_t *** plugins, size_t * numPlugins);
    db - The database the function acts on.
    plugins - The outputted array of active plugins. If the textfile-base load order system is being used, these plugins will be in load order, otherwise their order is undefined. If numPlugins is 0, this will be NULL.
    numPlugins - The size of the outputted plugins array.
    ...

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Referencing dll from another program

    Looks like a native dll. Look at pinvoke.net for prototype examples on calling native dlls from .Net. Or contact your vendor for example code of calling their dlls in .Net.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured