Multi instance

Discussion in '3CX Phone System - General' started by pat71, Jun 27, 2016.

Thread Status:
Not open for further replies.
  1. pat71

    Joined:
    Mar 17, 2016
    Messages:
    44
    Likes Received:
    0
    Hi,

    Do 3CX API works with multi instance application. Because i can see that the is hold statics Variables

    [DllImport("kernel32.dll", EntryPoint = "GetPrivateProfileStringA")]
    static extern int GetKeyValueA ( string strSection, string strKeyName, string strNull, StringBuilder RetVal, int nSize, string strFileName );

    So can we call to PBX From the same application?
     
  2. NickD_3CX

    NickD_3CX Support Team
    Staff Member 3CX Support

    Joined:
    Jun 2, 2014
    Messages:
    1,255
    Likes Received:
    63
    Yes you can. When I was toying around with it some time ago I had created the following method

    Code:
    private static PhoneSystem connectToInstance(string instanceNumber)
     {
                PhoneSystem.ApplicationName = "App Name"; //any name
                RegistryKey regKeyAppRoot;
                regKeyAppRoot = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\3CX\\PhoneSystem");
    
                var appPath = (string)regKeyAppRoot.GetValue("AppPath");
                appPath = Path.Combine(appPath, "Instance" + instanceNumber);
                var filePath = Path.Combine(appPath, @"Bin\3CXPhoneSystem.ini");
    
                var value = GetKeyValue("ConfService", "ConfPort", filePath);
                var port = 0;
                if (!String.IsNullOrEmpty(value))
                {
                    Int32.TryParse(value.Trim(), out port);
                    PhoneSystem.CfgServerPort = port;
                }
    
                value = GetKeyValue("ConfService", "confUser", filePath);
                if (!String.IsNullOrEmpty(value))
                {
                    PhoneSystem.CfgServerUser = value;
                }
    
                value = GetKeyValue("ConfService", "confPass", filePath);
                if (!String.IsNullOrEmpty(value))
                {
                    PhoneSystem.CfgServerPassword = value;
                }
    
                return PhoneSystem.Root;
    }
    
    Then I used to call this for all active Instances and store them in an Array and use them at will.

    Hope this helps.
     
  3. pat71

    Joined:
    Mar 17, 2016
    Messages:
    44
    Likes Received:
    0
    Hi,
    Thank you, But is this code for V14?

    I have develop application that monitor multi instance and interact with them at the same time please see this page

    http://www.alnayme.com/projects.aspx?proname=Mex Application for 3CX PBX

    I need way that i can keep the connection active for all instance at the same time, but the config setting in the API is static so i can not create new instance of the connection for each instance at the same time. but i can do that for one at time only.
     
Thread Status:
Not open for further replies.