Click here to Skip to main content
14,297,726 members
Rate this:
Please Sign up or sign in to vote.
See more:
So I generated a .dll from a LabView vi. The variable I'm trying to use is declared as follows:

typedef struct {
	long dimSize;
	LStrHandle elt[1];
	} TD1;
typedef TD1 **TD1Hdl;

The function I want to call is:
void __cdecl getFileList(TD1Hdl *SpecResults);

where, according to LabView, SpecResults is an output variable that I can use (it is an array in the vi).

I have gotten it to compile several different ways, but no matter what I do, I can't retrieve the data I need (dimSize and elt).

Here is the closest I've gotten:
int main(int argc, char *argv[])
   TD1 *tdptr = (TD1 *)malloc(sizeof(long) + (6 * sizeof(LStrHandle))); // the array I'm getting has 6 elements
   TD1Hdl tdhdl = &tdptr;


   return 0;

Debugging with watches for tdptr and tdhdl says "symbol not found" for both.

SetupWO() starts the main vi, getFileList is a subvi.

Thanks in advance for any help.

Adding the lines
if(tdptr = NULL)
   return 0;
   printf("memory allocated");

right after tdptr is declared gives dimSize = ??? and elt = 0x00000004, which I guess is a little better than what I was getting? I don't know, I need to get this figured out as I've been working on it all week and I can't make any more progress until I do. Any help is greatly appreciated...
Updated 10-Jun-11 6:04am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Unfortunately didn't get any answers on these boards but I have it more or less figured out. I'll post the code in case anyone has a similar problem in the future. It's separated into classes now so it looks a little different.


#include <ansi_c.h>
#include <labviewLib.h>
#include <iostream>
#include <stdlib.h>
#include "createMPTfile.h"

using namespace std;

class wrapper
    void run();
    ~wrapper(){delete create;}

    void LStrToCStr(LStrHandle lstr, char *cStrBuff, long buffLen);

    TD1 tdptr;
    TD1Hdl tdhdl;


#include "wrapper.h"

void wrapper::run()
    tdhdl = NULL;


    tdptr.dimSize = (*tdhdl)->dimSize;
    for(int i = 0; i < tdptr.dimSize; i++)
        tdptr.elt[i] = (*tdhdl)->elt[i];

        char atpString[256];
        LStrToCStr(tdptr.elt[i], atpString, 256);

void wrapper::LStrToCStr(LStrHandle lstr, char* cStrBuff, long buffLen)
    int32 len = LHStrLen(lstr);
        if(len >= buffLen)
            len = buffLen - 1;

    memcpy(cStrBuff, LHStrBuf(lstr), len);
    cStrBuff[len] = 0;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100