Creating DLLS in C/C++

Hey guys!!
I am new to JNI and I was trying the "Hello World" program in Java Tutorial to familiarise myself with DLLs and native methods - but I hit a snag [very discouraging indeed. ] I am tryng to create the dlls using the example given but I am getting an error saying that "file cannot be found" with lots. I suspected the "include" was wrong but I have tried to put it as it is setup on my pc to no avail. Can someone help out pls.

Well i 'm experiencing lots of problems too but try this :
in your C file put these include:
#include <jni.h>
#include <stdio.h>
#include <windows.h>
#include <HelloWorld.h>

Similar Messages

  • How to create dll in Visual Studio 2008 in Visual C++

    Hello,
    I have insatlled Visual Studio 2008. I have to create DLL in Project
    type Visual C++.
    Which Template i have to select to reate dll, MFC DLL or Class
    Library?.
    I have to call or import this dll in Windows Forms Application. How
    can i do this. Please give details procedure to do this.

    If we look at how  AFX_CLASS_EXPORT and AFX_CLASS_IMPORT  are defined in afxv_dll.h we see the following.
    #define AFX_CLASS_EXPORT __declspec(dllexport)
    #define AFX_CLASS_IMPORT __declspec(dllimport)
    So, when exporting our classes from our DLL we want the class declarations from the DLL to look like this:-
    class __declspec(dllexport) CMyClass : public CObject
    And, when importing our C++ classes into our application we want the class declarations from the DLL to look like this:-
    class __declspec(dllimport) CMyClass : public CObject
    OK, so here's how I do things.
    In the stdafx.h file for the export DLL, include two #defines at the bottom of the file like this:-
    #define _MYLIB_DLLAPI_
    #define _MYLIB_NOAUTOLIB_
    Now, in the main header file for your DLL, say mylib.h (the main 'point of entry' header for your DLL that you will include in you application later), add the following at the top:-
    // The following will ensure that we are exporting our C++ classes when
    // building the DLL and importing the classes when build an application
    // using this DLL.
    #ifdef _MYLIB_DLLAPI_
        #define MYLIB_DLLAPI  __declspec( dllexport )
    #else
        #define MYLIB_DLLAPI  __declspec( dllimport )
    #endif
    // The following will ensure that when building an application (or another
    // DLL) using this DLL, the appropriate .LIB file will automatically be used
    // when linking.
    #ifndef _MYLIB_NOAUTOLIB_
    #ifdef _DEBUG
    #pragma comment(lib, "mylibd.lib")
    #else
    #pragma comment(lib, "mylib.lib")
    #endif
    #endif
    Now, just declare all the C++ classes you want exported from the DLL like this:-
    (Note: Any C++ classes not declared with MYLIB_DLLAPI will not be exported from the DLL)
    class MYLIB_DLLAPI CMyClass : public CObject
    regards,
    Matt John
    complete variety of quilts is availabale here!
     PR: wait...
     I: wait...
     L: wait...
     LD: wait...
     I: wait...
    wait...
     Rank: wait...
     Traffic: wait...
     Price: wait...
     C: wait...

  • Creating dll and calling it in labview crashing the program

    Hi All,
    I am using labview from quite a long time.But this time i am stuck with dll.Not able to solve this issue.
    I have to communicate with FTDI chip.
    I have a VC++ Project to communicate with SPI of FTDI.That Code is working perfectly fine.
    Now I Have to automate that through LabVIEW. VISA Drivers i cant use in this. So Last option left is either to create dll or to make EXE out of it.
    I have tried by creating DLL and then calling it in LabVIEW by using Call Library Function Node.But its not helping me out every time LabVIEW is getting Crashed.
    Is there error in creation of dll or something i am not doing properly while calling?
    Thanks In Advance 
    Shweta
    Attachments:
    old_dolphin_sub_spi_func_ftdi.c ‏21 KB
    ftdi_write_read.vi ‏15 KB

    Which function call crashes LabVIEW?
    Have you tried switching the calling convention from stdcall to C for all of the DLL calls?
    Why are you converting a string to a number, instead of using a numeric constant directly? If you want a number in hex, you can right-click a numeric constant, make the radix visible, and switch it to hex display.

  • Creating dll in Labview

    Hello All,
    How do i create a dll in labview? I want to use it as a plug in into an application.
    Demmy

    Hi Demmy
    What LabVIEW version are you using? If you are using version 8 and higher then you have to have your VIs loaded into a LabVIEW project and you use the project build specification. You can access the LabVIEW 2009 help on how to build a dll here.
    Here is a quick summary:
    In the project window right click build specifications and choose New -> Shared Library (DLL). This will open the window to create the dll.
    Go to the Source Files category and use the arrow to take the VIs that you want into exported VIs, a dialog will then come up to define the function prototype for that vi. Do this for each vi you want to access in your dll.
    You will need LabVIEW professional version to create dlls and the target computer where you are using the dll must have the LabVIEW run time engine installed.
    Message Edited by Karissa on 03-03-2010 09:05 PM
    Systems Test Engineer
    Certified LabVIEW Architect (CLA)

  • Creating dll, lib, fp's to be used in other CVI programs

    Disclaimer: I am a self-taught CVI (and C) programmer in which I learned from examples, NI forums, and google  
    Main question: What is the proper way to create a dll, lib, and fp to be used in other CVI programs?  What I am doing is creating a "wrapper class" called PowerSupplies (and other wrapper classes) that takes arguments from the user and call the correct functions based on the power supply model type.
    Inside my Power Supplies project, I have included each power supply's function panel.  In the C file, I have added my functions and include file.  for example, here's one
    int _VI_FUNC Supply_InitSupply (int devs, char *resourceName, int IDQuery, int resetDevice, int *instrumentID) {
    switch (devs) {
    case AG663XXA:
    return ag663xxa_init(resourceName,IDQuery,resetDevice,instrumentID);
    case HPE364XA:
    return hpe364xa_init (resourceName, IDQuery, resetDevice, instrumentID); //Has Voltage and Current
    return -1;
    and then of course at the bottom, there resides the DllMain and DllEntryPoint functions.  What the heck are these, and am I suppose to rename these?  I ask because I created another wrapper classes with DMM's and I get the Multiply Defined Symbol Error with these two functions when using together in a separate program.
    Additionally, I have created a header file, which can be included in other CVI programs to know what functions there are.  I noticed I could "Generate Prototypes" after the fact and wasn't sure if this was the correct way or not.  My header file is below:
    #ifndef __PowerSupplies_H__
    #define __PowerSupplies_H__
    #ifdef __cplusplus
    extern "C" {
    #endif
    //==============================================================================
    // Include files
    #include "cvidef.h"
    #include "ivi.h"
    //==============================================================================
    // Constants
    #define POWER_SUPPLY_ENUM_FACTOR 200
    typedef enum
    AG663XXA = 200,
    HPE364XA
    } power_supply_type;
    static IviStringValueTable power_supply_table =
    {AG663XXA, "AG-663##X"},
    {HPE364XA, "HP-E364#A"}
    //==============================================================================
    // Types
    /************** Static Function Declarations **************/
    /************** Global Variable Declarations **************/
    /************** Global Function Declarations **************/
    int _VI_FUNC Supply_InitSupply(int devs,char *resourceName, int IDQuery, int resetDevice,int *instrumentID);
    /*commented out long list of functions for this forum's sake*/
    int _VI_FUNC Supply_Close(int devs, int instrumentID);
    int __stdcall DllMain(HINSTANCE hinstDLL,DWORD fdwReason, LPVOID lpvReserved);
    int __stdcall DllEntryPoint(HINSTANCE hinstDLL,DWORD fdwReason, LPVOID lpvReserved);
    #ifdef __cplusplus
    #endif
    #endif /* ndef __PowerSupplies_H__ */
    I then have built it as a static library and dynamic link library.  I then generated a Function Panel from the header file with Prefix Supply_ and Qualifier as _VI_FUNC.
    All worked nice and dandy, copied files to appropriate places in the IVI directory.
    In my other CVI program in which uses these "wrapper classes", I have included the function panel's that I created.
    Well with the error i mentioned above about Multiple Defined Symbol, I have come here to figure out what went wrong.
    What are the DllMain and entry point functions?
    Is my c and h files created correctly with proper prefixs?  I tried extern once, and got errors I believe.
    Does the function panel use the .lib files? Am I going about this correctly or is there an easier/more efficient way?
    Any and all advice is greatly appreciated!!!
    Thanks!

    There's info in the CVI help on how to make DLL,s in CVI.
    There's quite a bit more to it than you might imagine at first.
    I've pasted a DllMain that I wrote.
    Some key issues:
    You can put a type library into your DLL, that way if you add the DLL as a reference in Visual Studio, VS will know the prototype without your having to bring in a header file or import library of any kind.
    CVI created DLL's are not "active" DLL's and should not be registered with regsvr32, this will just make a mess.
    You can tell CVI what you're exporting in a couple of different ways, I always use "symbols marked for exports"  and use the macros DLLEXPORT DLLSTDCALL, but NI says using a header file is preferable, I forget why.
    The DLL search path is a wonderful thing - it's easy to wind up using a different copy of the DLL than you intended due to the way windows searches for the DLL.  Different versions of windows have slightly different rules.  Some allow redirection to help you manage the search path.
    CVI will not automatically switch between debug and release versions of the import library - you have to call out the correct version in your project and link it to any executable using it. 
    You can do "dynamic" loading / linking of a CVI DLL without binding to an import library using GetProcAddress function, but it's easier to use the import library.
    A DllMain isn't necessary but is good practice.
    Good luck.
    /*== PRAGMAS =====================================================================================================*/
    #if defined (_CVI_) && (_CVI_ >= 850)
      #if defined _CVI_DEBUG_
        #pragma C99_extensions_on  
      #endif
    #endif
    /*== INCLUDE FILES ===============================================================================================*/
    #include <windows.h>
    #include <userint.h>
    #include <ansi_c.h>                                                                                     
    #include <cvirte.h>
    #include <stdio.h>
    #include <utility.h>
    #include <analysis.h>
    #include <toolbox.h>
    #include <formatio.h>      
    /*== MACROS ======================================================================================================*/
    #define MAX_STRING_SIZE 256   
    #define MAX_MESSAGE_SIZE 256
    #undef  MAX_LOG_MESSAGE_SIZE
    #define MAX_LOG_MESSAGE_SIZE 256                                                
    #undef  WriteFile   // To deconflict formatio (CVI) version of this function
    #undef  ReadFile    // To deconflict formatio (CVI) version of this function             
    /*== TYPEDEFS ====================================================================================================*/
    // Data type providing reference structure for thread local storage (TLS).
    typedef struct ThreadData {
      CHAR ErrorString[MAX_STRING_SIZE];
    } ThreadData, * LPTHREADDATA;
    /*== MODULE SCOPE VARIABLES ======================================================================================*/   
    static FILE * logFileStream;                      
    static HANDLE hModule = INVALID_HANDLE_VALUE;
    /*== GLOBAL (HEAP) VARIABLES =====================================================================================*/
    // TLS index
    DWORD g_dwTlsIndex;
    /*== PROTOTYPES ==================================================================================================*/    
    /*== CODE ========================================================================================================*/  
    * Function: DllMain
    * Description:
    *    DLL Main entry point.  Provides for DLL initialization.  
    * Limitations:
    * Parameters:  System defined.
    * Return Value:
    BOOL WINAPI DllMain (HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved) {
      LPTHREADDATA lpThreadData;      
      switch (fdwReason) {
        case DLL_PROCESS_ATTACH:
          // Allocate a TLS index.
          if ((g_dwTlsIndex = TlsAlloc ()) == 0xFFFFFFFF) return FALSE;
          hModule = hInstDLL; 
          // No break - fall through and initialize for main thread
        case DLL_THREAD_ATTACH:
          lpThreadData = (LPTHREADDATA) calloc (1, sizeof (ThreadData));
          if (lpThreadData != NULL) TlsSetValue (g_dwTlsIndex, lpThreadData);
          lpThreadData = TlsGetValue (g_dwTlsIndex);
          lpThreadData->ErrorString[0] = '\0';     
          break;
        case DLL_THREAD_DETACH:
          // Release the allocated memory for this thread.
          lpThreadData = TlsGetValue (g_dwTlsIndex);
          if (lpThreadData != NULL) free (lpThreadData);
          break;
        case DLL_PROCESS_DETACH:
          // Free the allocated memory for this thread (main thread).
          lpThreadData = TlsGetValue (g_dwTlsIndex);
          if (lpThreadData != NULL) free (lpThreadData);
          // Release the TLS index.
          TlsFree (g_dwTlsIndex);
          break;
      return TRUE;
    } // end, DllMain
    INT DLLSTDCALL DllEntryPoint (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
      // Included for compatibility with Borland
      return DllMain (hinstDLL, fdwReason, lpvReserved);
    } // end, DllEntryPoint
    implement dll functions like this:
    int DLLEXPORT DLLSTDCALL myFunc (int iParam) {
      return 1;

  • Create dll with arrays and call it

    I am trying to create dll with labview in order to pass a 2d array to the main program. The problem is that I don't really know how to create the function to call it (I don't know much about pointers)
    The function I have created to call the dll is void Untitled1(TD1Hdl *Array1) which is suposse to return the array created on it.
    For example, in the program attached, how should I do to pass the array to another program using dlls?
    Thanks a lot,
    Juanlu
    Attachments:
    Untitled 1.vi ‏7 KB

    The code you've provided doesn't do anything (just a control wired to an indicator) so I'm not sure what you're asking here.
    If I understand correctly, you want to build a DLL from your LabVIEW VI.  From what language will you call that DLL?  There is no standard way to pass a 2-D array.  If you can convert to a 1-D array, you can use a simple pointer.  With a 2-D array, you're stuck with LabVIEW's array representation (the TD1Hdl type), which means that whatever code calls that function will need to understand the LabVIEW data type and how to manipulate it.

  • JNI: experience in creating DLLs with G++ (mingw32)?

    Hello.
    I'm trying to create a DLL:
    --------------/HelloWorld.cpp/------
    #include <jni.h>
    #include "HelloWorld.h"
    #include <stdio.h>
    JNIEXPORT void JNICALL
    Java_HelloWorld_displayMessage(JNIEnv *env, jobject obj)
    printf("Hello world!\n");
    return;
    I previously created 'HelloWorld.java'
    class HelloWorld
    public native void displayMessage();
    static
    System.loadLibrary("HelloWorldImp");
    I created 'HelloWorld.class'.
    I created the header file 'HelloWorld.h':
    c:> javah -jni HelloWorld
    But I do not have any idea to create the DLL.
    I tried with:
    c:> g++ -I"D:\j2sdk\include" -I"D:\j2sdk\include\win32" HelloWorld.cpp -shared -o HelloWorldImp.dll
    But I get this error message when calling from 'Main.java':
    Exception in thread "main" java.lang.UnsatisfiedLinkError: displayMessage
    at HelloWorld.displayMessage(Native Method)
    at Main.main(Main.java:6)
    In order to get this message I created 'Main.java':
    class Main
    public static void main(String[] args)
    HelloWorld hello = new HelloWorld();
    hello.displayMessage();
    Does anybody have any experience in creating DLLs with G++???
    Thank you very much.

    Or is it better GCC?

  • Problem in creating DLL for a LabVIEW VI

    Hi
    I am facing problems in creating DLL for a LabVIEW VI. Previously i had no problems in creating DLL for the VI that transmits a message from serial port to NI - PXI 7831-R Reconfigurable I/O card (configured by FPGA MOdule). When i try the same VI with a customized port developed using IVI drivers i am not able to create the DLL. It gives me error as follows:
    Fatal Internal error: "datamgr.cpp", Line No: 1882
    Please somebody help me out to fix this error.
    Regards,
    Subramania Bharathi

    Hi,
    Thanks for your curiosity in replying my questions. I am really sorry for replying so late. Actually the problem was with the NI SWITCH 2503 functions. Actually i was multiplexing the channels of my customized serial port using NI Switch module. This switching is done before i start my communication. My VI follows a sequence as follows.
    1. Connect two channelss using Switch functions
    2. configuration of both FPGA and the customized port
    3. Transmit data from the port
    4. Receive it in FPGA.
    5. Reset the channels using Switch functions
    I never expected that the error was because of NI Switch. When i removed them from my VI i was able to create the DLL and able to create sequence successfully to run in the Testsand. And
    further i am using Switch Executive for swithcing the channels in TestStand.
    But now i am very curious why it posted me that error when i used my NI Switch function?? I tried to create DLL for a VI that switches two channels and i was successful. But the error occurs only when i combine i with my FPGA functions!! If you could trace out the reason, please let me know
    Once again thanks a lot for your support
    Regards,
    Subramania Bharathi

  • Create DLL from labview and calling it from other application

    I have an application built using Labview. I wanted to create DLL out of it. The application has
    two String inputs start and stop buttons and two status indicators.
    1. How to itegrate start and stop buttons from function prototype?
    2. Does Labview created DLLs requires labview runtime engine when it is to be called from other application?
    Can some one help on this.
    Solved!
    Go to Solution.

    Hi Yuvish,
    1) They should be boolean inputs to your VI. But does it makes sense to provide a stop button input at the start of your VI? (THINK DATAFLOW!)
    2) Yes, the LV-RTE is needed...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Create .dll

    i don't know how to create dll file, which i want use to link with another file(.lib), any one can help? thanks in advance!

    You need a C++ compiler.Linker, you meant. Which he probably has... I'd say what he needs is the documentation for that linker which will tell him the correct flags for generating a shared lib.

  • Creating DLL and identifyin​g LVRTE for 32bit/64bi​t/WinXP/Wi​n7

    I have a labVIEW 2010 application (created on 32bitXP) to be distributed
    for
    -Windows XP 32 bit
    -Windows XP 64 bit
    -Windows 7  32 bit
    -Windows 7  64 bit.
    What kind of runtime engine will I need?
    I also found that
    - there is no runtime engine available for WinXP64 bit, what do I do for
    this
    OS?
    - there are multiple runtime engines for LV2010 (min/std/64bit).
    Can someone pls help me to dentify,
    Which link to use for which OS/bit combination with LV 2010.
    Also can someone help me to identify, if I need to build the application
    (EXE
    or DLL) in 4 different ways, for these 4 OS?
    regards
    Sandeep
    NI Software :  LabVIEW  version 2010
    NI Hardware :  None device

    Hi Greg,
    Thank you for your response too.
    Yes, I must have 32 bit RTE for running 32 bit DLL.
    And also I do want to have 32 bit DLL only (& not 64 bit one).
    To explain, let me propose the following case.
    I have a C# created (built in 32 bit mode for x86) parent EXE .
    I have C# created (built in 32 bit mode for x86) child DLL.
    The child DLL gets called successfully by parent EXE. In all 4 possible OS combinations. ie. 32bitWinXP,64bitWinXP,32bitWin64,64bitWin64.
    But..
    When I create a 32 bit DLL from 32 bit LabVIEW on XP32bit,
    it never gives me success to be called by 32 bit C# parent in 64bitWinXP, 32bitWin7, 64bitWin7.
    I am aware that I must not create 64bit DLL, becasue my C# EXE is built in 32 bit (& That's how it must be to be able to run in all 4 OS combinations).
    Below is my thread
    http://forums.ni.com/t5/LabVIEW/Creating-DLL-and-i​dentifying-LVRTE-for-32bit-64bit-WinXP-Win7/m-p/13​...
    Thanks for reading thru.

  • Create dll from labview

    Hi all:
    I am using labview 8.5 , i want to create dll for spacific vi , to use its output in another program like C++,
    can any one help me to learn the steps to create dll from labview
    thanks

    You need the application builder (which is part of the professional distro).
    In general you should every VI that you want as a function set to 'top-level'
    If you right click on the builds in your project you have an option to build a DLL (if you have the application builder), from there on the help is available.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Trying to create DLL from VI to use in TestStand.

    I trying to create a DLL out of an existing VI file.  The VI has about 4 inputs and about 3 outputs.  If I go to Tools >> Build Application and select the Build Target as a "Shared Library (DLL)" i get a dll after the build; but when I try to call that DLL from teststand, it doesn't recognize any of the inputs or outputs.  How do I build a DLL so that teststand will reconize the inputs and outputs?
    Solved!
    Go to Solution.

    The controls and indicators are connected to the connectors.  Also, answering an earlier post, the prototype information for the inputs and outputs are not automatically displayed. I can manually define the prototypes, but then the question is how does each prototype link to its corresponding parameter (by name?). I've also tied creating just a simple VI that has just one string input and one string output.  I built the VI to a DLL and tried calling in TestStand and i get the same results.  I've inserted the resulting header file after that build.  Which, by the way, looks exactly like my other created DLL's header file.  The difference in bold(the name of the VI). Which makes me thik that my build DLL process might be off.
    #include "extcode.h"
    #pragma pack(push)
    #pragma pack(1)
    #ifdef __cplusplus
    extern "C" {
    #endif
    void __stdcall String_input_output(void);
    long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module);
    #ifdef __cplusplus
    } // extern "C"
    #endif
    #pragma pack(pop) 

  • How to create dll file from c code to use in compactrio 9004 RT controller

    Hi.
    I am using Compactrio 9004 Real time controller and i am new to this. I have a C code and i want to use this with the RT controller.I red that that can be done by creating a dll file and can be called in labview.Can any body expalin how to create a DLL from the c code and be used with this RT controlelr?
    Regards,
    Vishnu

    vishnu123 wrote:
    Hi,
    Earlier in this forum itself in cRIO 900x controllers will run Pharlap and run C/C++ code compiled into .dll files.Can you please tell how to transfer the created DLL to RT controller memory throght FTP?
    Thanks and regards,
    Vishnu
    There is another KB article about this for Pharlap based controllers. And you are right the earlier CompactRIO controllers were Pharlap based. Basically for a deployed application to work, you need to put the DLL through FTP in "/ni-rt/system". If you deploy it directly from the project everything will be loaded into memory through the project environment itself including directly dependable DLLs, (but of course won't survive a power cycle).
    I hope you are aware that while Windows DLLs can work on Pharlap OS they by no means will do so always. The Pharlap OS has not a fully featured Windows API. Also you need to be careful which version of Visual C you are going to use depending on the Pharlap OS version, since the VC runtime DLLs already present on the controller will need to be the same as the ones your Visual C environment likes to link in. Recent Pharlap OS versions use the msvcr71.dll. It's very possible that those runtime libraries can't just simply be copied from a normal Windows installation but might have been recompiled by NI specifically for their controller targets.
    So to avoid problems it's a good idea to make sure your DLL uses the same runtime library DLL or make your DLL to include the static MS runtime.
    Rolf Kalbermatter
    Message Edited by rolfk on 02-05-2008 09:51 AM
    Message Edited by rolfk on 02-05-2008 09:53 AM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Is the LV RTE necessary to run a LV created dll?

    Is it necessary to install the LabView RTE when a LV created dll is to be accessed by a C based program?  I am guessing that the answer is both yes and no.  I have a feeling that the RTE is only needed when specific LV resources are used.  If so what resources would trigger the need for the RTE?

    You always need the LabVIEW Run-time Engine installed on a machine where you will be calling a LabVIEW-built DLL.
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • How do I call a LabVIEW created DLL from within Microsoft Excel (VBA)?

    Hi,
    I'm trying to get Microsoft Excel 2003 to call a function stored in a dll that I created using LabVIEW 7.1.  The function is very simple and is called "binary_file_to_ascii".  Basically it just reads a LabVIEW created binary spreadsheet file and outputs the columns as float arrays.
    The function arguments are as follows:
    INPUT : String that contains the path to the binary spreadsheet file
    OUTPUT : Number of rows in the spreadsheet
    OUTPUT : Number of columns in the spreadsheet
    OUTPUT : Float array containing the elements in column 1
    OUTPUT : Float array containing the elements in column 2..
    OUTPUT : Float array containing the elements in column 11
    However, for some reason there is something wrong with my VBA code and/or the way I created the DLL in LabVIEW because Excel crashes when it loads my DLL.
    What do I need to change in my VBA code or my LabVIEW DLL build settings to fix this?
    I've attached to this post a ZIP file that contains all my code and a sample binary file.
    Your help with this will be much appreciated.  Thanks!
    Richard
    P.S.  Here is the VBA code I'm using:
    Private Declare Function binary_file_to_ascii Lib "C:\temp\binary_file_to_ascii\binary_to_ascii.dll" _
    (ByVal binaryFile As String, ByVal nrows As Long, ByVal ncols As Long, ByVal column1 As Variant, _
    ByVal column2 As Variant, ByVal column3 As Variant, _
    ByVal column4 As Variant, ByVal column5 As Variant, _
    ByVal column6 As Variant, ByVal column7 As Variant, _
    ByVal column8 As Variant, ByVal column9 As Variant, _
    ByVal column10 As Variant, ByVal column11 As Variant)
    Private Sub load_binary_spectra()
      Dim nrows, ncols As Long
      Dim col1(), col2(), col3(), col4(), col5(), col6(), _
          col7(), col8(), col9(), col10(), col11() As Variant
      Dim lRetVal As Long
      Dim spectra_path As String
        spectra_path = "C:\temp\binary_file_to_ascii\sample_binary_file\sample_binary_file.dat"
        lRetVal = binary_file_to_ascii(spectra_path, nrows, ncols, _
                  col1(), col2(), col3(), col4(), col5(), col6(), _
                  col7(), col8(), col9(), col10(), col11())
        MsgBox (spectra_path)
    End Sub
    Message Edited by Richard Ballantyne on 07-25-2007 02:39 PM
    Message Edited by Richard Ballantyne on 07-25-2007 02:39 PM
    Attachments:
    binary_file_to_ascii.zip ‏192 KB

    Hi,
    I don't know anything about Visual Basic, but here's my guess.
    When you load the DLL with this line of code
    Private Declare Function binary_file_to_ascii Lib "C:\temp\binary_file_to_ascii\binary_to_ascii.dll" _
    (ByVal binaryFile As String, ByVal nrows As Long, ByVal ncols As Long, ByVal column1 As Variant, _
    You are defining how the parameters are sent. It seems that all are sent by value (ByVal), but in the DLL header, some of the function's
    parameters are defined as pointers(see the function prototype below, look for asterisk(*))
    void __stdcall binary_file_to_ascii(PStr binaryFile,
                                                    long *numberOfRows,
                                                    long *numberOfColumns,
                                                    float column1[],
                                                    float column2[],
                                                    float column3[],
                                                    float column4[],
                                                    float column5[],
                                                    float column6[],
                                                    float column7[],
                                                    float column8[],
                                                    float column9[],
                                                    float column10[],
                                                    float column11[]);
    Can you define in VBA that you want to use pointer instead? Maybe by using ByRef (as by reference).
    Hope this helps.

Maybe you are looking for

  • Aperture STILL won't launch

    Aperture stopped launching this morning. I tried the fix suggested in another thread of replacing the Prokit.framework with an older version but it didn't work for me. Unfortunatley that discussion is marked as answered and has gone off in another di

  • Applet, Application communication

    Hi Someone tell me how to do applet, application communication. I have one standalone application, running in server and receiving connection from applets and every min. the server has to send some data back to each apllet connected. How to do it...

  • Nokia Repair Center And Customer Service

    Hello, I am contacting you today regarding a problem that I have with the repair center. The reason that I am contacting YOU, is because no else (Email support or customer services phone numbers) that I have been dealing with seem to know they are do

  • Metadata Panel in Bridge - Greyed Out - what did I do?

    I am using CS2 and the metadata panel (view - Metadata panel) is greyed out. What can I do to make it active? Thanks very much. Joanne

  • I have lost my address-book from my iphone5.

    i have lost my contacts from my iphone. i have a feeling i had deleted them from the address book of my Mac book. now when i try to restore the contacts from the backup I had taken on my macbook the contacts are restored but in 30-45mins they disappe