Jump to content

Simple string in and out of a DLL created with LabVIEW


Recommended Posts

Good morning,

I have a DLL I created (in Labview)  that takes in string information, does some magic crunching on it to create a password that is passed out as a string.  This DLL will be called from CVI and probably from a C# application.

This should be so simple, however I cannot figure out how to pass the string in and get the modified string out of my DLL.

I've had no luck at all getting this DLL to work by trying many different things.  It crashes LV, returns and error, or simply passes nothing out during my trials.

I've included the project (its small) in zipped format.  Can one of you kind souls take a look at my code and tell me what I'm doing wrong, or what I need to do correctly to both, configure the DLL and then call it from LabVIEW?

 

Thank you!

 

Randy

Password Generator.7z

Link to comment

I don’t have LabVIEW 2016 and can’t open your code, but you might be trying to change a parameter directly.  C calls pass parameters by-value, not by-reference, so changing any of the parameters in the function will not affect their value in the calling code.  

Edited by drjdpowell
Link to comment
  • 1 month later...
On 1/2/2017 at 5:22 PM, Randall956 said:

Good morning,

I have a DLL I created (in Labview)  that takes in string information, does some magic crunching on it to create a password that is passed out as a string.  This DLL will be called from CVI and probably from a C# application.

This should be so simple, however I cannot figure out how to pass the string in and get the modified string out of my DLL.

I've had no luck at all getting this DLL to work by trying many different things.  It crashes LV, returns and error, or simply passes nothing out during my trials.

I've included the project (its small) in zipped format.  Can one of you kind souls take a look at my code and tell me what I'm doing wrong, or what I need to do correctly to both, configure the DLL and then call it from LabVIEW?

 

Thank you!

 

Randy

Password Generator.7z

It would actually help if you saved the VIs for previous. I haven't installed LabVIEW 2016 here. However as far as calling the function in the header file is concerned, something like this should definitely work, if you didn't mess up the configuration of the DLL build script (which I can't control for lack of LabVIEW 2016).

#include "Password.h"

#define BUF_LENGTH 100

char input[] = "some text";
char output[BUF_LENGTH];

MakePassword(inpupt, output, BUF_LENGTH);

printf("This is the converted text: %s", output);

I'm not sure about your C programming experience, but if you have little to none, the trick is most likely in providing a valid buffer for the output string and not expect the function to handle that automatically like you are used in LabVIEW!

Edited by rolfk
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.