I'll try my best to keep this query as compact as possible...
I'm currently working on a project that involves generating alarms/notifications for the Automated Distributed Control System at the company. Well, for this, the team has created Notification Client and Notification Server Applications.
There is also another .exe created that dumps a message (the message is taken from a database, by means of a function) into a Private queue (which can be viewed in the Computer Management tool). This .exe is intended to run alongside the Notification Server Application, which accesses the queue to obtain the messages, which are then displayed at the User Station by means of a method created (called rhsc_notifications; I'll detail that later).
The problem we are facing is that the display at the User station is truncated, i.e. in all fields, only the first character is displayed, and remaining data is missing. (The alarm/notification is displayed as multiple fields like Alarm generation location, priority, description, time, etc.).
This problem is faced when the Notification Server uses a method called rhsc_notifications directly. However, one of the team members created an interface in Visual Basic. This interface is called by the Notification Server, and the interface processes the message, and calls the rhsc_notifications method to display the message at the User Station. When this interface is used, the display turns out fine, no truncation. However, when the rhsc_notifications method is called directly from the Notification Server Application, there is truncation.
We are required to eliminate this interface, and call rhsc_notifications method directly. The thing is that this method uses a library that has NOT been developed in a .Net environment. Hence, there is the need to marshal the data.
We've tried a few things with marshaling, but the problem hasn't been resolved. So I'm hoping you guys will be able to help me out with this...
So, here's the code part of it then:
The rhsc_notifications method is as follows:
int rhsc_notifications (char *szhostname
int cjrnd
NOTIFICATION_DATA* notd);
Here, szhostname is the server host name;
notd is a pointer to an array of NOTIFICATION_DATA structures (one array element for each request);
cprmbd is the number of notifications requested.
The structure of the NOTIFICATION_DATA structure (which is defined in another header file), is as follows:
You know, when Jelsoft invents the version of vB that automatically detects code and places code tags around it, they will be able to charge 3 times as much for the software.
Three5Eight Using: MS C# 08 EE, MS SQL 05 EE, C++ .Net 08 EE, Vista Home Premium, XP Home
what datatype is n_long? is it a 64 or 32 bit int? typically C++ long converts to C# int, and there would be no need to add the UnmanagedType.I8 on that.
my first try would be something like this (depending on the size of n_long being an unsigned 32 bit int)
Code:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct TimeB {
public int Priority;
public int SubPriority;
[MarshalAs(UnmanagedType.LPStr, SizeConst=20)]
public string Name;
[MarshalAs(UnmanagedType.LPStr, SizeConst=20)]
public string Event;
[MarshalAs(UnmanagedType.LPStr, SizeConst=20)]
public string Action;
[MarshalAs(UnmanagedType.LPStr, SizeConst=20)]
public string Level;
[MarshalAs(UnmanagedType.LPStr, SizeConst=50)]
public string Description;
[MarshalAs(UnmanagedType.LPStr, SizeConst=20)]
public string Units;
[MarshalAs(UnmanagedType.LPStr, SizeConst=20)]
public string Value;
public int Status
}
Bookmarks