473,748 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inerop help

Greetings,

I apologize for re-posting this, but I'm running out of options on my
side.

I've got a DLL that's not COM compatible and I'm stuck using interop
for the first time. I got couple of simple DLL calls all right but
cannot get the most important one to work.

Here is documentation:

---

int LoadSymbol( char*sym, void *data , int max_rec , bool
IGNORE_HOLIDAYS = true , bool RAWDATA = true ,usr_master_def *MasterRec
= 0);

Returns: Number of days loaded. Negative number indicates an error.

Parameters:

sym - Points to the stock symbol to load.

data - Points to an array of type Stock_Record.

max_rec - An integer value...

IGNORE_HOLIDAYS - Boolean value...

RAWDATA - Boolean value...

---

Here is C++ example:

....
char symbol[12];
#define MAX_RECS 10000;
Stock_Record data[MAX_RECS];
....
num = LoadSymbol( symbol , &data[0] , MAX_RECS , FALSE , TRUE , 0 );
....

Here is a definition for Stock_Record struct:

typedef struct
{
char MM;
char DD;
short YY;
float open;
float hi;
float lo;
float cl;
long vol;
char RS;
float oi;

} *LPSTOCK_RECORD , Stock_Record;

I don't know if a definition for Master_Rec is necessary (the last
argument for LoadSymbol function) since they just passed 0 in the
example. Pardon my naivety if it's totally wrong assumption.

Anyway, when I call this function (LoadSymbol) I got a positive number
returned meaning that records have been read. The only problem - they
have no data.

Here is C#:

[DllImport("read er.dll")]
public static extern int LoadSymbol(stri ng symbol, Stock_Record[]
records, int maxDays, bool ignoreHolidays, bool rawData, int
masterRecord);

(I might have screwed up with "int masterRecord" part...). The
following is C# brother of Stock_Record:

[StructLayout(La youtKind.Sequen tial, CharSet=CharSet .Ansi)]
public struct Stock_Record
{
public string MM;
public string DD;
public short YY;
public float open;
public float hi;
public float lo;
public float cl;
public long vol;
public string RS;
public float OI;

}

And some execution code:

....
Stock_Record[] records = new Stock_Record[100];
int daysLoaded = LoadSymbol("MSF T", records, 100, false, true, 0);
....

The situation here is that "records" array contains elements with
default values - Stock_Record doesn't get populated.

Any help would be greatly appreciated (I really mean it).

Thank you.

Feb 10 '06 #1
1 1189
ste
Are you sure your c# Stock_Record matches the sizeof() for the c struct
typedef struct // num bytes
{
char MM;
char DD;
short YY;
float open;
float hi;
float lo;
float cl;
long vol;
char RS;
float oi;

} *LPSTOCK_RECORD , Stock_Record;
C' chars are 1 byte and i dont think they map onto C# strings.. which are
probably sizeof( a pointer ) [ a guess ]
Try changing your strings in your mapped record to 'byte' .. eg and make
sure you map the C sizeof(long) to its .net counterpart

The C' short is 2bytes and you should probably use int16 on 32bit machine.


"yuriy_zuba rev" <yu***********@ yahoo.ca> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. . Greetings,

I apologize for re-posting this, but I'm running out of options on my
side.

I've got a DLL that's not COM compatible and I'm stuck using interop
for the first time. I got couple of simple DLL calls all right but
cannot get the most important one to work.

Here is documentation:

---

int LoadSymbol( char*sym, void *data , int max_rec , bool
IGNORE_HOLIDAYS = true , bool RAWDATA = true ,usr_master_def *MasterRec
= 0);

Returns: Number of days loaded. Negative number indicates an error.

Parameters:

sym - Points to the stock symbol to load.

data - Points to an array of type Stock_Record.

max_rec - An integer value...

IGNORE_HOLIDAYS - Boolean value...

RAWDATA - Boolean value...

---

Here is C++ example:

...
char symbol[12];
#define MAX_RECS 10000;
Stock_Record data[MAX_RECS];
...
num = LoadSymbol( symbol , &data[0] , MAX_RECS , FALSE , TRUE , 0 );
...

Here is a definition for Stock_Record struct:

typedef struct
{
char MM;
char DD;
short YY;
float open;
float hi;
float lo;
float cl;
long vol;
char RS;
float oi;

} *LPSTOCK_RECORD , Stock_Record;

I don't know if a definition for Master_Rec is necessary (the last
argument for LoadSymbol function) since they just passed 0 in the
example. Pardon my naivety if it's totally wrong assumption.

Anyway, when I call this function (LoadSymbol) I got a positive number
returned meaning that records have been read. The only problem - they
have no data.

Here is C#:

[DllImport("read er.dll")]
public static extern int LoadSymbol(stri ng symbol, Stock_Record[]
records, int maxDays, bool ignoreHolidays, bool rawData, int
masterRecord);

(I might have screwed up with "int masterRecord" part...). The
following is C# brother of Stock_Record:

[StructLayout(La youtKind.Sequen tial, CharSet=CharSet .Ansi)]
public struct Stock_Record
{
public string MM;
public string DD;
public short YY;
public float open;
public float hi;
public float lo;
public float cl;
public long vol;
public string RS;
public float OI;

}

And some execution code:

...
Stock_Record[] records = new Stock_Record[100];
int daysLoaded = LoadSymbol("MSF T", records, 100, false, true, 0);
...

The situation here is that "records" array contains elements with
default values - Stock_Record doesn't get populated.

Any help would be greatly appreciated (I really mean it).

Thank you.

---
avast! Antivirus: Inbound message clean.
Virus Database (VPS): 0606-4, 10/02/2006
Tested on: 10/02/2006 22:32:38
avast! - copyright (c) 1988-2005 ALWIL Software.
http://www.avast.com



---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0606-4, 10/02/2006
Tested on: 10/02/2006 22:42:27
avast! - copyright (c) 1988-2005 ALWIL Software.
http://www.avast.com

Feb 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
6553
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help Workshop program: hcw.exe that's included with Visual Basic. This exact same file compiled perfectly with no notes, warnings or errors prior to reformatting my system. Prior to the reformatting, I copied the help.rtf file onto a CD and checked the box to...
6
4346
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing result in any way. Who can help me, I thank you very very much. list.cpp(main program) //-------------------------------------------------------------------------- - #pragma hdrstop #pragma argsused
3
3362
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With numarray, help gives unhelpful responses:
1
1260
by: yuriy_zubarev | last post by:
Greetings, I apologize for re-posting this, but I'm running out of options on my side. I've got a DLL that's not COM compatible and I'm stuck using interop for the first time. I got couple of simple DLL calls all right but cannot get the most important one to work. Here is documentation:
0
8983
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8822
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9310
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8235
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6792
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4592
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3298
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.