Page 1 of 1

Visual Studio 2010 C#

Posted: Wed Oct 31, 2012 10:06 pm
by heopas
I have some problems with API. I can' t make it work (build).
I am newb in C# :D

Code:

Code: Select all

public Form1()
        {
            InitializeComponent();
            for (int i = 1; i <= 3; i++)
            {
                int len = Enigma_IDE.EP_ProtectedStringByID(i, null, 0);
                if (len > 0)
                {
                    StringBuilder str = new StringBuilder(len);
                    if (Enigma_IDE.EP_ProtectedStringByID(i, str, len) > 0)
                    {
                        if (i == 1)
                            encdecpass = str.ToString();
                        if (File.Exists(Directory.GetCurrentDirectory() + "\\users.ini") == false)
                        {
                            File.Create(Directory.GetCurrentDirectory() + "\\users.ini");
                            IniFile ini = new IniFile(Directory.GetCurrentDirectory() + "\\users.ini");
                            if (i == 2)
                                username = str.ToString();
                            else
                                password = str.ToString();
                        }
                    }
                }
            }
        }

        public class Enigma_IDE
        {
            [DllImport("enigma_ide.dll", CallingConvention = CallingConvention.StdCall)]
            public static extern Int32 EP_ProtectedStringByID(Int32 ID, StringBuilder Str, Int32 Len);
        }
Errors:

Code: Select all

Error	1	The type or namespace name 'DllImport' could not be found (are you missing a using directive or an assembly reference?)	C:\******\Visual Studio 2010\Projects\login\login\Form1.cs	47	14	login
Error	2	The type or namespace name 'DllImportAttribute' could not be found (are you missing a using directive or an assembly reference?)	C:\******\Visual Studio 2010\Projects\login\login\Form1.cs	47	14	login

Re: Visual Studio 2010 C#

Posted: Thu Nov 01, 2012 1:18 am
by perfectcode
text removed

Re: Visual Studio 2010 C#

Posted: Thu Nov 01, 2012 9:55 am
by heopas
Nice !! That worked for me.
Now i have another problem, when i am getting the first protected string i am sending a messagebox to test it. The string contains only the first letter from the protected string. (e.x. Protected String: heopas MessageBox: h).
I have already tried to chagne ascii string to wide.

Edit1:
I changed the int to int32 and is fixed.
Now the problem is that it add a extra character at the end (using ascii) ( E.x. Protected String: heopas MessageBox: heopas} )
Same problem occur with Enigma Example too.