Jump to content
News about the LabVIEW Wiki! Read more... ×
Randy_S

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Strings are tricksy since there are a few ways that it can be done and sometimes dependent on how the DLL was created.

Here is an example.

Call Generator2.vi

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

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