LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I use CIN functions within a Win32 DLL?

I understand that it is possible to use CIN functions within a Win32 DLL. I have managed to get to the point where I don't know what is going wrong. I have "labview.lib" being linked correctly and there are no other compliation errors. The problem is a linking error as follows:

---------------------------------------
Linking...
Creating library Debug/cwst.lib and object Debug/cwst.exp
cluster_with_string_test.obj : error LNK2001: unresolved external symbol _DSSetHandleSizeOrNewHandle
c:\LV Dev\bin\cwst.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

cwst.dll - 2 error(s), 0 warning(s)
---------------------------------------

The code is this:

// -----------------------------
-------
#include "extcode.h"

__declspec(dllexport) long create_handle(LStrHandle out);

__declspec(dllexport) long create_handle(LStrHandle out)
{
MgErr err = DSSetHandleSizeOrNewHandle(out, 7);

MoveBlock("you win", out, 7);

return (err);
}
// ------------------------------------

I'm guessing there's something missing in my setup so here's what I've noted as being the important changes to the default project settings that I have done. I am running Microsoft Visual C++ 6.0sp5, Enterprise edition:


In Project->Settings..

  • C/C++ Tab:
    1. Set "Additional include directories", under the "Preprocessor" option, to the cintools directory (absolute path).

    2. Set "Struct member alignment" to "1 Byte" under the "Code Generation" option.

    3. Set "Use run-time library" to "Multithreaded DLL" under the "Code Generation" option. (NOTE: Using "Debug Multithreaded DLL" causes a LNK4098 warning)


  • Link Tab:

    1. Added a /li
      bpath option to "Project Options" that points to the cintools directory (absolute path).



Thanks for any help!
Naveen

0 Kudos
Message 1 of 3
(3,056 Views)
Naveen;

Try the following code (NOTE: I haven't test it, so I am not completely sure it will work):

// Resize "out" LV string to accomodate "you win"

long str_size = strlen("you win") // = 7

err = NumericArrayResize(uB, 1L,(UHandle *)&out, str_size);

// Update the length of the "out" LV string
LStrLen(*out)=str_size;

// Move Templ_Size bytes from Temp_buffer to "out" LV string
MoveBlock("you win", LStrBuf(*out), str_size);

return (err);

Regards;
Enrique
www.vartortech.com
0 Kudos
Message 2 of 3
(3,056 Views)
Thanks.
0 Kudos
Message 3 of 3
(3,056 Views)