I have only DLL and text file of API description from customer (see below). I don't have any more details regarding the DLL. I don't know the Delphi version etc.
I tried to use both of API functions but was not successful. Generally first two parameters of string[255] (PatientID and AccessionNo) are important. Any my attempts to pass strings to that DLL don't provide proper result. I see random garbage values or part of strings in application GUI. I looked at all related question on this site and searched in the internet but didn't find anything which helped me.
OpenStudy function - I tried different settings for CharSet = CharSet.Ansi and Auto, for MarshalAs all suitable values (see below). I see the garbage random value in the managed application GUI text fields.
[DllImport("Lib\\RISInterface.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, EntryPoint = "Open_Study", ExactSpelling = false)] static extern internal int OpenStudy( // try to use here and for all string fields [MarshalAs(UnmanagedType.AnsiBStr)] , LPStr, LPTStr, LPWStr, BStr, TBStr, HString string PatientID, string AccessionNo, bool CloseCurrentStudy, bool AddToWindow, int SeriesRows, int SeriesCols, int PresentationMode, bool AutoTile, bool AutoLoad, bool RemoteExam);
OpenStudy1 function - I fill the structure and call function. I see PatientID and AccessionNo as normal string but PatientID misses the first letter and AccessionNo misses the first two letters. ( send: "qwerty", "12345" and see: "werty", "345")
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct TIQStudyAutomation { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 255)] public string PatientID; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 255)] public string AccessionNo; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 255)] public string StudyUID; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 255)] public string SeriesUID; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 255)] public string InstanceUID; public bool CloseCurrentStudy; public bool AddToWindow; public int SeriesRows; public int SeriesCols; public int PresentationMode; public bool AutoTile; public bool AutoLoad; public bool RemoteExam; public bool LoadFromAllSources; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 255)] public string ArchiveName; } [DllImport("Lib\\RISInterface.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, EntryPoint = "Open_Study1", ExactSpelling = false)] static extern internal int OpenStudy1(TIQStudyAutomation automationInfo);
================= API description ==========================================
These function declarations are Delphi Code and all string references are Ansi strings.
function Open_Study(PatientID, AccessionNo: PAnsiChar; CloseCurrentStudy, AddToWindow: Boolean;
SeriesRows, SeriesCols, PresentationMode: Integer;
AutoTile, AutoLoad, RemoteExam: Boolean): Integer; stdcall;
Return
Error Code.
Remarks
The parameters will be packed into a TIQStudyAutomation record and passed to Open_Study1.
//--------------------------------------------------------------------------------------------------
function Open_Study1(AutomationInfo: TIQStudyAutomation): Integer; stdcall;
Return
Error Code.
Parameters
Takes a TIQStudyAutomation record.
//--------------------------------------------------------------------------------------------------
TIQStudyAutomation = record
PatientID, AccessionNo, StudyUID, SeriesUID, InstanceUID: STRING[255];
CloseCurrentStudy, AddToWindow: BOOLEAN;
SeriesRows, SeriesCols, PresentationMode: Integer;
AutoTile, AutoLoad, RemoteExam, LoadFromAllSources : BOOLEAN; ArchiveName: STRING[255];
end;
Any help?