Call a Borland Delphi DLL with Structs from LabView

Hello,
I have a problem to build an equivalent Struct in Labview to the following Struct which I want to retrieve from a DLL.
type
TM2DScanline=record
YWert:double;
XWert:array[0..raster] of double;
ZWert:array[0..raster] of double;
IWert:array[0..raster] of byte;
end;
M2DScanArea =array[0..maxScans] of TM2DScanline;
PointerToScanArea=^M2DScanArea;
PointerToScanArea is the parameter I want to retrieve.
If anybody knows a way for doing this, help would be very appreciated
Thanks
Peter

Are raster and maxScans both constant? If I recall correctly, many dialects of Pascal just lay the elements of a fixed-size array out in memory with no size parameter; if this is the case with Delphi, then you may be able to do the following (in my example, I'll assume "raster" is a constant set to 40, and maxScans is a constant set to 5):
Create a cluster called XWert with 40 Numeric elements (representation: DBL).
Copy XWert and name the copy ZWert.
Create a cluster called IWert with 40 Numeric elements (representation: U8).
Create a cluster called TM2DScanline.
Create a Numeric inside TM2DScanline called YWert (representation: DBL).
Drag XWert, then ZWert, then IWert into TMD2Scanline.
Create a cluster called ScanArea and drag 5 copies of TMD2Scanline into it.
Create a Call Library node on your block diagram, give it your DLL and function name, and set the return value to whatever your Delphi function returns. You probably want the WINAPI calling convention.
Add a parameter and make it "Adapt to Type: Pointers to Handles". Close the node and wire the ScanArea cluster to the input.
Right-click on the Call Library Node and select "Create .c file...." Read through the C file to make sure its structure is similar to your Delphi record: you should see five copies of the TM2DScanline structure, each of which contains a double followed by two fixed 40-element structures of double and a fixed 40-element structure of unsigned char. You should see no reference to the word "Hdl" anywhere in the code.
This strategy will only work if the arrays in your records are fixed at a constant size, and if Delphi lays out the arrays in memory as described above. Instead of doing all this work, you may want to write a small C or Pascal wrapper around your Delphi function. This wrapper could take simpler parameter types (which are easier to use from LabVIEW) and bundle them into the cluster before calling your Delphi function.

Similar Messages

  • Calling a VB Script and Matlab code from LabVIEW GUI.

    Hi,
    Can anyone help me out in Calling a VB Script and Matlab code from LabVIEW GUI? GUI will be developed in Labview and currently we have some scripts written in VB and Matlab and we need to incorporate the same through LabVIEW. Can anyone let me know how this can be implemented? 
    Regards,
    Sharmash

    For VBScript you can call the Windows Scripting Host application using the System Exec function, or you can use IScriptControl, which is an ActiveX control. Be aware that with the IScriptControl there's a small bug. You can read more about it in this post.
    For Matlab, there's a Matlab node that you can use. You can either copy and past your Matlab script in the node, or just write a function call statement. The node simply calls Matlab. Or, you can do as suggested and use the MathScript node, which is basically an alternative to Matlab. The MatchScript node doesn't support everything that Matlab does, so you will need to check it against your script.
    Or, you can do as suggested, and rewrite it all in LabVIEW, unless you can't because these scripts are used by other applications.

  • How to call c functions that expects c structs from java program?

    i need to call from my java program to c functions that get
    c structs as a parameters in their prototype.
    as you probablly know java is not working with structs (classes only), so my question is how can i do it , i mean call the c functions that gets structs as parameters form java????

    i believe your c function can accept a jobject and then inside your c function you have to translate that jobject into a c struct by using the jni methods.
    the only reason your c function cant accept structs from java is because java does not have such structures. your c function can accept any data type that has been defined and a jobject has been defined.
    if you have no control over the c functions that are being called, you need to write a wrapper function for those c function. the wrapper functions do the translation from jobject to a struct...then call the c other c functions.

  • Run DLL in C++ from Labview

    Hi the world !
    Ive got a pb in labview when I call my DLL or in VB6 when I build my DLL.
    Join my project... what do you think about my pb ?
    thanks for help !
    Ben.
    Attachments:
    LancerDLL.zip ‏35 KB

    candidus a écrit:
    OK, I got your gift :-)
    It's pretty useless to use new[] inside your function, static arrays will do it.
    The question is, how does your caller allocate the arrays?
    It's a bad idea to use operator delete[] on arrays you given as parameters:
    You should allocate them, call you dllbeta1() function which shouldn't modify these parameters
    and deallocate them in your caller function.
    I can't look into your VI, I don't have 8.6 but since we're in a LabVIEW forum
    I assume you want to call your DLL from LabVIEW.
    LabVIEW has its own memory management
    which doesn't just use new[]/delete[] so you shouldn't modify strings in your DLL unless
    you're familiar with the memory management functions in "extcode.h".
    And be careful to use the right calling convention: __cdecl or __stdcall
    Calling convention is __cdecl.
    My dll doesn't modify these parameters... just uses for functions.
    Have you got a solution for me ?
    thanks

  • Calling external C-functions in DLLs with struct as parameters

    Hi all PL/SQL Gurus !
    Is it possible to call external functions in a DLL written in C
    wich has pointers to C-structs as parameter. Can you point me to
    an example or extended documentation about this. I had a look at
    the Oracle doc's but found no examples about structs.
    Thank you very much,
    Stefan.
    P.S.: Konfiguration: Oracle 8.1.7.0.0 Client and Server on W2K-
    SP2 machines.

    Hi,
    I have the same problem with you.Now,have you resolve the problem?
    I want to know how to do.if you resolve it ,could you give me a example.
    thanks .
    best regards!
    Liyf

  • Interface dll function with struct in LabVIEW

    Hello,
    I have a function:
    HPDF_SetInfoDateAttr  (HPDF_Doc pdf, HPDF_InfoType type, HPDF_Date value) 
    The problem is in the last input, HPDF_Date value. HPDF_Date is a struct which looks as followed:
    typedef  struct  _HPDF_Date {
        HPDF_INT    year;
        HPDF_INT    month;
        HPDF_INT    day;
        HPDF_INT    hour;
        HPDF_INT    minutes;
        HPDF_INT    seconds;
        char        ind;
        HPDF_INT    off_hour;
        HPDF_INT    off_minutes;
    } HPDF_Date;
    Now I created the following cluster in LabVIEW:
    In the Call Library VI I set the type to "Adapt to type" and tried the dataformats. However none of them worked. Can any one explain to me why the cluster is not accepted by the function? I know the error is there because the error function of the dll says that I input an invalid datetime format.
    The datetime format may look like this:
    Member
    Effective values
    year
    month
    Between 1 and 12.
    day
    Between 1 and 28, 29, 30, or 31. (Depends on the month.)
    hour
    0 to 23
    minutes
    0 to 59
    seconds
    0 to 59
    ind
    Relationship of local time to Universal Time (" ", +, −, or Z).
    off_hour
    If "ind" is not space, 0 to 23 is valid. Otherwise, ignored.
    off_minutes
    If "ind" is not space, 0 to 59 is valid. Otherwise, ignored.
    Solved!
    Go to Solution.

    Actually LabVIEW can. A struct passed by value is simply pushed element for element onto the stack. So instead of defining a structure to pass as a single parameter to the CLN, you configure the CLN to take one parameter per structure element (and use the right datatype of course).
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Import DLL with unicode in Labview

    Hi all,
    i am developing a software user-friendly to control a home-made microscope. I would like to install a Andor camera and to control it i have to import the dll of Andor SDK v3 but Labview cannot see any function from the header file because of a Unicode compatibility with LAbview (apparently Labview cannot read Unicode from the dll). Do you have any idea how to solve my problem ?
    thanks
    regards
    Philippe

    The problem you are having is a limitation with the Import Wizard. You should be able to configure the Call Library Function Node manually. As for Unicode support in general, you should read this article: http://decibel.ni.com/content/docs/DOC-10153

  • How to open a text-file with notepad from labview-vi?

    Hello,
    how can i execute a program from a vi?
    I want to open a textfile with Windows7-Notepad after selelecting it from a file-path-control and pressing an open-button.
    Thx for help
    Solved!
    Go to Solution.

    Use the command line.  Something like cmd /c notepad c:\temp\blah.txt should work.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Multiple numeric test with cluster from labview?

    Is it possible to make a multiple numeric limit test with the values from a cluster from a labview vi?
    Solved!
    Go to Solution.

    This can be done with a little work.
    The first step is to get the cluster's data back in to TestStand's memory space as you would do normally.
    Then you either use post expressions (since you're at a point in time between the test code module completing and the status evaluation) to move the pertinent parts in to the data source for the step (usually step.numericarray) or...
    http://zone.ni.com/reference/en-XX/help/370052K-01/tsref/infotopics/test_step_types_mnl_test/
    And
    http://zone.ni.com/reference/en-XX/help/370052K-01/tsref/infotopics/pane_mnl_datasource/
    Use the 'specify data source for each measurement''.
    I'm not in front of a computer with TestStand right now to knock up an example but it should be pretty straight forward.
    Either method should allow you to work with a mixed cluster of data types and just evaluate on the numeric ones.
    Thanks
    Sacha
    // it takes almost no time to rate an answer

  • Calling Borland C++ DLL

    want to call my borland c++ 5 or 6 generated DLL, is it possible ?
    any samples or steps I can follow ?
    thanks.

    Richard Zhu wrote:
    > want to call my borland c++ 5 or 6 generated DLL, is it possible ?
    >
    > any samples or steps I can follow ?
    There shouldn't be any specific problem with calling Borland compiled
    DLLs with the Call Library Node in LabVIEW, provided the DLL is
    installed properly with all necessary Borland runtime DLLs on the target
    system.
    As to examples check out the examples/dll directory in LabVIEW. DLLs are
    supposed to be a standard format and it should not make any difference
    if they are created with Visual Studio, Borland C or even gcc.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Swing Form = JNI = Delphi DLL = Delphi Form works but small issue

    Hi all
    I'm trying to call a delphi dll from a java form.
    This is the procedure
    swing button action => jni => call procedure in delphi dll => create delphi formThis works for me but the problem is when click the button it create the delphi form by calling the dll but it's stucked for ever(frame not the whole form). Never return to do something else. Means that it's stay remain in clicked postion.
    I do not know whether the problem exist with the swings' single threaded behavior. I have used another thread to call natives. But the problem persist.
    So can any one suggest any answer.
    Wish U all HAPPY NEW YEAR!
    Here is the compact code
    native calls
    public class LoadLib
        public native void createForm();
        public native void forward();
        static
            System.loadLibrary("testjni");
    }calling class
    import javax.swing.*;
    import java.awt.event.ActionEvent;
    import java.awt.Container;
    import java.awt.event.ActionListener;
    public class RUNClient extends JFrame {
         JFrame frame = new JFrame();
         JFrame frame2 = new JFrame();
         LoadLib lib = new LoadLib();
         JButton b1 = new JButton("OK");
         JButton b2 = new JButton("Forwad");
         private RUNClient() {
              frame.setLayout(null);
              frame.add(b1);
              frame.add(b2);
              b1.setBounds(110, 80, 80, 20);
              b2.setBounds(110, 50, 80, 20);
              b1.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        lib.createForm();     // create form in dll
                        // after this call frame is stucked
              b2.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        lib.forward();          // call another native to do some in created form
                        // this cannot be called because frame is stuck
              // other frame operation
         public static void main(String args[]) {
              new RUNClient();
    }delphi code
    library testjni;
    uses
      JNI,Unit1;
      var
      f : TForm1;
    procedure Java_LoadLib_createForm(PEnv: PJNIEnv; Obj: JObject); {$IFDEF WIN32} stdcall; {$ENDIF} {$IFDEF LINUX} cdecl; {$ENDIF}
    begin
    try
      f := TForm1.Create(nil);
      f.ShowModal;    
       finally
         f.Free;
         f.Release;
       end;
    end;
    procedure Java_LoadLib_forward(PEnv: PJNIEnv; Obj: JObject); {$IFDEF WIN32} stdcall; {$ENDIF} {$IFDEF LINUX} cdecl; {$ENDIF}
    begin
    Form1.Top := Form1.Top - 50;
    end;
    exports
      Java_LoadLib_createForm,
      Java_LoadLib_forward;
    begin
    end.

    Hi deshan,
    To realize the problem you should know principles of Java GUI (SWING or AWT) implementation in JVM:
    1) Java GUI is implemented in a single thread with EventQueue static object, which is created with JVM when Java Application GUI starts.
    2) Any painting or event calls are done on this thread (the same approach was used by Microsoft in .NET GUI).
    3) While your code handles an event EventQueue waits for return from your event method. Some calls to GUI components can stick the whole Java GUI (this is the problem of SUN Java architecture, I did not have this in Microsoft Java). To avoid this problem you should use InvokeLater method that works like PostMessage to the main thread in Windows Application. InvokeLater generate an event that is posted to EventQueue and your code passed to InvokeLater method will be executed asynchronously in GUI Thread.
    4) If you call any Java (SWING or AWT) component from the thread other than EventQueue thread you must synchronize these calls with locks by the object got from getTreeLock() method of the component you call. But you should be accurate with locks because they can cause deadlocks.
    Your code does not return from Click Event where you try to create some GUI component but EventQueue is still waiting for “return” and the main GUI thread is suspended.

  • Can I control Unholtz-Dickie VWIN ver. 4.61 software from Labview?

    Unholtz-Dickie VWIN is a Window-based application that controls a vibration system. I want to coordinate the vibration control with the acquisition of data from the unit under test.

    Hello,
    I just did a quick websearch and wasn't able to find any information on getting LabVIEW to work with this VWIN software of which you speak. If this software has ActiveX capabilities, you should be able to communicate with it from LabVIEW without any problems...LabVIEW has the ability to control other programs with its ActiveX tools. If your VWIN software does not support ActiveX, however, your options are rather limited...you could use the "System Exec" VI in LabVIEW to launch the VWIN software from LabVIEW, but you would have no control over it from LabVIEW.
    There are other ways of communicating between programs (DLL calls, simple ASCII text file writing, etc.), but these would not be as easy as ActiveX. You may want to contact the manufacturer of this softwar
    e and ask them if they known of any of their customers attempting to control the software externally, and if so, what methods they used.
    I wish you luck with your application. Also, in the future please post LabVIEW-related question in the appropriate LabVIEW forum.
    Have a pleasant day.
    Sincerely,
    Darren N.
    NI Applications Engineer
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Import c struct from dll header file into TestStand?

    Hi,
    I'm writing a TestStand sequence to call some CVI functions I have compiled into a dll. One header file in the CVI code is the interface to the dll and declares some functions and some C structs which are to be passed into the functions as pointers. These structs are populated with test results as the CVI code executes. I want to import these structs into TestStand.
    TestStand seems to have properly imported my function calls because I can select them from a drop-down list. But it doesn't seem to recognize my struct definitions, because it just says "unknown __struct 617*" -- it knows it's a C struct pointer but doesn't know what fields exist in the struct.
    How do I get TestStand to recognize the fields that are in my structs?
    The C functions and structs are declared with DLLEXPORT in the header file. I compile the CVI code into a dll, with the target settings set to export marked header files and symbols. The only header file marked in the target settings dialog is the header file declaring these functions and structs. So I think they're being exported properly into the dll.
    Any ideas to help?
    Thanks!

    I'm using typedef struct {...} MyStruct; to make life easier in CVI world, so rather than changing that throughout my CVI code I think I'll just live with the fact that TestStand doesn't know what struct type it is.
    But typedef or not, is it ever possible for TestStand to import the struct definitions (ie so that it knows what fields and types exist within the struct)? Or do I have to make containers in TestStand that match the format of the structs I'm using in CVI, and pass those container pointers into my CVI function calls?
    Thanks!

  • Call library with struct as parameter - several problems

    Hi everyone,
    I'm trying to send a MIDI sysex message to a midi device through winmm.dll using MidiOutLongMsg. I have trouble figuring out how to pass the parameters right.
    I need to call three functions (midiOutPrepareHeader, midiOutLongMsg, midiOutUnprepareHeader), all of them having the same form
    MMRESULT midiOutPrepareHeader(
    HMIDIOUT hmo,
    LPMIDIHDR lpMidiOutHdr,
    UINT cbMidiOutHdr
    where HMIDIOUT hmo is a handle that I have already. Troubling me are the other two parameters. cbMidiOutHdr is the size (in bytes) of the struct lpMidiOutHdr. This is a struct of the form
    typedef struct {
    LPSTR lpData;
    DWORD dwBufferLength;
    DWORD dwBytesRecorded;
    DWORD_PTR dwUser;
    DWORD dwFlags;
    struct midihdr_tag far * lpNext;
    DWORD_PTR reserved;
    DWORD dwOffset;
    DWORD_PTR dwReserved[4];
    } MIDIHDR;
    (Struct: http://msdn2.microsoft.com/en-us/library/ms711592.aspx
    PrepareHeader http://msdn2.microsoft.com/en-us/library/ms711634.aspx
    SendMessage http://msdn2.microsoft.com/en-us/library/ms711629.aspx
    UnprepareHeader http://msdn2.microsoft.com/en-us/library/ms711641.aspx)
    [Note: The full code for what I want to do can be found here http://www.borg.com/~jglatt/tech/lowmidi.htm (section "outputting system exclusive MIDI messages) - basically I need a translation of this code to LabView.]
    The following are my problems:
    a) How do I emulate a struct in LabView? (other threads suggest that this is done by clusters)
    b) How do I pass a pointer to a struct (cluster?) to a DLL?
    c) If I can use a cluster for this struct, how do I represent the LPSTR lpData in the cluster, i.e., a pointer to my data?
    d) how do I get the struct size for cbMidiOutHdr?
    This is how far I got, lots of it with the help of several threads in this forum:
    a) use a LabView cluster
    b) use "adapt to type" in the dll call (couldn't get this to work)
    c) I use a type cast on my string in the hope that what it returns is the register address (and I'm probably superwrong here)
    d) my cluster consists of 9 elements of 4 byte datatypes, so I just use 36 for cbMidiOutHdr
    The dll seems to be happy with the way I pass the cluster - I get error codes of 0 in both the PrepareHeader and UnprepareHeader functions. However, sending doesn't work (error code 7). Guessing that the type cast returns a pointer, I have also cast the cluster to an Int32 and passed that parameter as pointer to numeric value. Interestingly, the PrepareHeader and UnprepareHeader functions are still happy, but I get a different error code from the sending (code 11)
    Most of what I've done so far is guesswork, and I'm out of guesses now. I've attached the code to this post (it uses VIs from the NI MIDI example library ftp://ftp.ni.com/pub/devzone/epd/midi-example.llb ). I'd appreciate any help with this. Thanks!
    Attachments:
    Write MIDI SysEx Message.vi ‏21 KB

    First off, this problem doesn't have anything to do with control references; those have meaning only inside of the LabView environment.
    My first suggestion is to look for a higher-level library that will do whatever MIDI function you are trying to call. If you can find an ActiveX or .NET object that will control the MIDI subsystem, I recommend that you use it instead since it will be a lot easier.
    If calling the DLL directly is the best option (and calling DLLs is absolutely the way to go when you need high performance) then you need to understand how LabView passes data to library functions. That is described here:
    http://zone.ni.com/reference/en-XX/help/371361D-01/lvexcodeconcepts/configuring_the_clf_node/
    As you can see there are a lot of ways to pass data, but they boil down to this: LabView can pass, via various levels of dereferencing, a pointer to some [mostly] flat data. Things are easiest when your DLL mimics LabView's own data storage methods. For example, wiring a cluster into a node set with Adapt to Type passes a handle (struct**, pointer to pointer to [mostly] flat data). So if you are writing your own DLL, it's pretty easy to write something that works nicely with LabView data (e.g., strings with 4-byte length headers, self-describing arrays) and in fact the result is cleaner looking than its "pure C" variant because of the self-describing arrays and string length prefixes. (I say "mostly" flat because LabView clusters with variable-length elements aren't stored in a flat format.)
    When it comes to matching someone else's API things get harder, and in this case you are out of luck; you are going to have to write a LabView-callable wrapper function in C because LabView can't mimic the exact data structure needed. The problem is not the struct; there is a sneaky way to pass a pointer (vs a handle) to a struct, which is to do this:
    Generate a cluster in LabView representing the struct (atomic numeric data only! no strings arrays etc!)
    Flatten to string using native byte order.
    Convert string to byte array.
    Configure the call library function note to accept a pointer to an unsigned byte array. (NOT a C-string as suggested at the bottom of the page in the link above; your data may have internal 0x00s, and it certainly doesn't need an extra 0x00 at the end!)
    The reason this works is that a pointer is just an address; as long as all the right bytes are in memory in the right order starting at that address, all is well. The DLL doesn't know that LabView thinks it is passing a pointer to an array of bytes, it just gets the pointer to the first byte and it reads and interprets those bytes according to its own struct def. Reverse the process cooming back from the DLL (convert byte array to string, unflatten from string against the LV cluster.) This method will work for any flat struct.
    In LabView 8.5 there may be a less bogus way of doing this, which is to pass the cluster in with Adapt to Type and select "Array Data Pointer" as the format. This is new and I haven't tried it.
    But in your case, you want to point to a struct that contains a pointer to a string plus some numeric data and another pointer, and this you can't do directly. LabView does not expose the location of a string to you anywhere outside the Call Library Function node, so there's no way to "find the pointer" to a LabView string from outside the DLL. What you need to do in this case is write a wrapper function in C that takes your LabView data. Only then will LabView "tell you where the bytes are" and promise not to fiddle with them until the library call is complete. Once you are in C-land, you can throw pointers around to your heart's content. As long as you do it all perfectly, all will be well. (If you write one byte too many on output, boom! :-)
    There are a few ways to do this. You could make a cluster that has meaning in LabView, e.g. replace lpData with a LabView string, then pass the cluster in to your wrapper function set to "Adapt to Type"; that will pass a handle to the cluster. You can generate the .c file from the Call Lib Fuction, and it will outline where the data is.
    Complications: In this case it's your job to convert the handle to the labview string (which has 4 bytes of length as a prefix and no trailing 0x00) to a C-string by malloc()'ing a new buffer and memcopying the string out. There might be something in the LV CIN tools that does this, I'm not sure. Make sure you release the new string after the MIDI call.
    The lazy route (which is what I would do) is pass the string as the first arg and all of the numeric stuff as the second arg, leaving the space for lpData as you have now. (I don't know what struct "midihdr_tag" is, but if that's not something you were passed in a previous call, you'll need to add a third argument for that cluster and treat it similarly.) Then you can tell LabView that it should pass the string arg as a C-string pointer. Inside your wrapper, extract the pointers and stuff them into the data structure as needed. Dereference once (to go from handle to pointer) and make the MIDI call. To be clean, put everything back where it was before in the cluster; in particular don't believe you can pass out lpData* and do whatever you want with it in LabView; LabView will release/change that address as soon as you leave the output string unwired or do anything to it (e.g. concatenate.) You'll be creating a new string buffer and a new pointer on your next MIDI call.
    All of this complication is a result of a) LabView's hiding the details of memory allocation/deallocation from you and b) LabView's internal data structures being a bit different from C conventions (e.g. LabView strings vs. C strings). The second means that even when LabView is using non-flat data structures (e.g. cluster containing an array), you can't just blindly pass them along to a C function and expect it to work right. It would be nice if NI would write a little mini-compiler into the Call Library Function that would do what our wrapper function is going to do, but that's probably a fairly significant project. 
    Still, each function wrapper is only going to have about 10 lines of C. You can put wrappers for all the MIDI functions you want to call into a single DLL, then ship that DLL with your app.
    (Now you see why I suggested you look for an ActiveX MIDI control!)
    -Rob Calhoun

  • How to pass data from a Delphi pascal DLL class to a LabView data cluster?

    Hi all,
    I have the following problem:
    I'm using a dll written in Delphi Pascal to transfer data to LabView using the "Call Library Function Node".
    My Delphi dll contains this class:
      TFlash=class
        Fi:TFileInfo;
        constructor Create;
        procedure LoadFi(Filedir_and_nametring);
      end;
     TFileInfo=record
        Idx:smallint; 
        IdxLstSpl:array[0..4] of longint;
        Ms:word;
        Sp:array[0..4]of word;
      end;
    I've created the TFileInfo record datastructure into a LabView cluster to have the "same" variable.
    My plan was to call a Deplhi DLL function with the "Call Library Function Node" and to pass the address of the TFileInfo record, so the data would be passed to the LabView Cluster.
    When I make a simple delphi dll function like this, it works because I only pass an small integer to Labview (without reference to the data structure):
    var  Data:TFlash; 
    function GetNrOfRows(FilePath: string):integer;stdcall; 
    begin
      Data:=TFlash.Create;
      Data.LoadFi(FilePath); //this function gets the number of rows out of the selected file.
      Result := Data.Fi.Idx;
    end;
    When I try to use this procedure instead of the function above, to pass the address of the whole complex data structure of "Data" (TFileInfo), I'm unable to get the information of "Data" into my Labview cluster:
    procedure LoadFileInfo(FilePath: string; DataPointer: Pointer);stdcall; 
    begin
      Data:=TFlash.Create;
      Data.LoadFi(FilePath);
      DataPointer:=@Data;
    end;
    Call Library Function Node settings:
    - stdcall (WINAPI)
    - Run in UI Thread
    - Function prototype: void LoadFileInfo(PStr FilePath, void *DataPointer);
          * DataPointer --> Type: 'Adapt to Type' and Data format: 'Pointers to Handles'.
          * FilePath --> Type: 'string', string format: 'pascal string pointer'
    I'm struggeling with this problem for almost a week now and I can't really find a solution on the forum or google.
    I've also read the following posts:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=229930&requireLogin=False
    http://forums.ni.com/ni/board/message?board.id=170&message.id=77947&requireLogin=False
    http://forums.ni.com/ni/board/message?board.id=170&message.id=51245&requireLogin=False
    (or did I miss something in these posts?)
    Hope my explanation is clear.
    Thx
    Solved!
    Go to Solution.

    Ok, I'm one step further:
    Because it works when passing an integer from the dll to Labview,
    I tried a simple vi containing a cluster with an small integer (16 bit signed Integer) in it and passing the pointer to that cluster:
    same settings:
    Call Library Function Node settings:
    - stdcall (WINAPI)
    - Run in UI Thread
    - Function prototype: void LoadFileInfo(PStr FilePath, void *DataPointer);
          * DataPointer --> Type: 'Adapt to Type' and Data format: 'Pointers to Handles'. (and the cluster wired to the output of the Call Library Function Node)
          * FilePath --> Type: 'string', string format: 'pascal string pointer'
    Changed the Delphi function to:
    procedure LoadFileInfo(FilePath: string; DataPointer: Pinteger);stdcall; 
    begin
      Data:=TFlash.Create;
      Data.LoadFi(FilePath);  --> this function fills in the data in Data.Fi
      DataPointer^:=Data.Fi.Idx; --> write the smallint on the address given by Labview
    end;
    When I call my DLL this way, the expected value appears in smallint indicator in de cluster on the front panel.
    When I'm passing a pointer from the TFileInfo Type:
    Delphi:
    var  Data:TFlash;
    type  PtrTFileInfo = ^TFileinfo;
    procedure LoadFileInfo(FilePath: string; DataPointer: PtrTFileInfo);stdcall; 
    begin
      Data:=TFlash.Create;
      Data.LoadFi(Copy(FilePath,2,length(FilePath)-1));
      DataPointer^:=Data.Fi;
    end;
    During debugging in my Delphi environment: when I get out of this function and pass this to Labview, an error occurs: access violation at 0x004E7125: read of address failed 0x00002A24. Process stopped.
    Is it actually possible to access data with 2 applications? Delphi--> common stack <--Labview

Maybe you are looking for

  • XML BURSTING PROGRAM

    Hello All, I have customized an oracle application program with xml publisher.The program prints the report in PDF format. My questions is where this output copied in the server .I am not able to find the pdf report in $APPLCSF/out/. Do i need to use

  • PHD no longer able to be created on workstation

    Yesterday, I set up a MacBook and created a PHD. I target-moded an old PowerBook G4 so as to migrate (manually) some info from PBook to MBook. The Finder copies hung a few times (bad Firewire cable I presumed), so I stopped it. I then restarted, and

  • Stretching type on a path

    I know you can only work with one path at a time, but is there anyway to create type on a path that stretches each letter as the word goes on? Basically, The bottom arc drops sharper than the top arc, but I would like to type to stretch proportionall

  • New PC!!! Not starting!! #2

    Every time the power is turned on the fans start, there are four red LED's on the D-Bracket followed by one green and three red (Early chipset Initialization as said in manual). This is the part I am having problems with, after I see these LED's the

  • Can I downgrade my ios?

    With the latest update my phone has not been working properly. My service goes in and out. I can't play my music on either my phone or ipad. (I updated my iPad as well)