Hi Guys,
I need some urgent help with this as I am becoming clueless now.
I have 2 DllImport as below from Kernel32
Now, I have made my DLL called CustomDLL.DLL which maps the second one properly. However, I am trying to use this and convert one above aswell and this is where i am not sure what to do.
***this doesnt work*******
****this works fine*********** *
Please help, how do i make the not working bit working here. Any help will be appreciated as this is very very urgent!
I need some urgent help with this as I am becoming clueless now.
I have 2 DllImport as below from Kernel32
Code:
[DllImport("kernel32")] private static extern int GetPrivateProfileString(string section, int key, string defaultValue, [MarshalAs(UnmanagedType.LPArray)] byte[] result, int size, string fileName); [DllImport("kernel32")] private static extern int GetPrivateProfileString(string section, string key, string defaultValue, StringBuilder result, int size, string fileName);
***this doesnt work*******
Code:
private static int GetPrivateProfileString(string section, int key, string defaultValue, [MarshalAs(UnmanagedType.LPArray)] byte[] result, int size, string fileName) { StringBuilder res = new StringBuilder(Encoding.ASCII.GetString(result)); int ret = IniFile.GetPrivateProfileString(section, key.ToString(), defaultValue, res, size, fileName); result = Encoding.ASCII.GetBytes(res.ToString()); return ret; }
Code:
private static int GetPrivateProfileString(string section, string key, string defaultValue, StringBuilder result, int size, string fileName) { return IniFile.GetPrivateProfileString(section, key, defaultValue, result, size, fileName); }
Please help, how do i make the not working bit working here. Any help will be appreciated as this is very very urgent!
Comment