Win32 API calling by Code Interface Node

Hi all,
I wish to call a Win32 API function by using the code interface node.
However, I don't know the data types in LabVIEW corresponding to the "HANDLE
*" in Visual C++.
Here's the function I wish to call:
BOOL bOpenDriver (HANDLE * phDeviceHandle, PCHAR devname) {
*phDeviceHandle = CreateFile(devname,
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
if (*phDeviceHandle == INVALID_HANDLE_VALUE) {
return (FALSE);
} else {
return (TRUE);
Thank you in advance.
JJ

If this is really a Windows API function, then the handle can most likely be treated as an I32.
Note that you can't actually do anything with the handle other than passing it to other functions.
If you search this site for "LabVIEW" and "DLL" you should find some resources about working with DLLs and Win32 API DLLs.
Try to take over the world!

Similar Messages

  • Using code interface node with dll crashes LV 2011 but not LV 8.6... using max error handling does nothing

    Hi all,
    I'm having a peculiar problem.
    I inherited a project saved in LabVIEW 8.6. The project must use of particular dll that was built a few years ago. The original developer and source code for this .dll are long gone. The very core logic exists, in the form of embedded C code, and that's it. The .dll is called through a Code Interface Node in LV 8.6 and this setup manages to "work". Howver, running the VI that calls this .dll in LV 2011 causes an "insta crash", as in, no "program has stopped responding".  Error message pops up, then all LV windows close.
    It's very similar to that described in here:
    http://digital.ni.com/public.nsf/allkb/D84C9775ABD921CF8625772A005CA50C
    but this KB says to try putting the amount of error handling to maximum. I tried that, but it didn't help. 
    Using the "Debug" option allows me to run the just-in-time debugger with CVI 2010, which then proceeds to say this:
    Finally, I manage to get this out of it: 
    FATAL RUN-TIME ERROR:   Unknown source position, thread id 0x000012D4:   A non-debuggable thread caused a 'General Protection' fault at address 0x00000000.
    I don't think that really helps at all, but it's there.
    Here is the function prototype of the .dll:
    void  _inputPM@224(uint8_t arg1, uint16_t arg2, uint8_t arg3, float arg4, float arg5, float arg6, float arg7, float arg8, float arg9, float arg10, float arg11, float arg12, float arg13, float arg14, float arg15, float arg16, float arg17, uint16_t arg18, uint16_t arg19, uint16_t arg20, uint16_t arg21, uint16_t arg22, uint16_t arg23, uint16_t arg24, uint16_t arg25, uint16_t arg26, float arg27, float arg28, float arg29, float arg30, float arg31, float arg32, float arg33, float arg34, float arg35, float arg36, float arg37, float arg38, float arg39, float arg40, float arg41, float arg42, float arg43, float arg44, float arg45, float arg46, float arg47, uint16_t arg48, uint16_t arg49, uint16_t arg50, uint16_t arg51, uint16_t arg52, float arg53, float arg54, float arg55, float arg56);
    (never seen a function take 50 input params like that (wouldn't you use a struct? array? something? But I digress, and I don't know anything about .dlls...))  
    I do have a ".lib" and a ".cdb" file with the same name as the .dll, but those also looks like some kind of compiled file. 
    I'm sure the answer I'm going to get is that there is no way of telling what's really going on without .dll source code. I'm hoping against hope that there may be another way or hack.
    Any ideas? Thank you for you help. 
    Regards,
    Mark G 
    Solved!
    Go to Solution.

    MarkCG wrote:
    Changing the call library node to stdcall (WINAPI) did the trick! No more crash. Thank you very much!
    I haven't run LV2011 on windows XP, only on windows 7, so I don't know if that makes a dfference. But  The call type makes no difference when using LV 8.6 on the same machine, however.
    Now I've got to make the .DLL run corretly on a compact fieldpoint....  and avoid crashing IT. 
    Thank you for the help all!
    Well, the DLL did work fine in LabVIEW 8.6 because earlier versions of LabVIEW automatically proceeded to change the calling convention to stdcall, if they noticed a function name decoration of @# (# = number of bytes passed on the stack) appended to the name. This is the default naming decoration for stdcall functions used by VisualC. However this decoration can be overwritten with linker switches, other compilers don't use them always in the same way, and most likely there are in the mean time compilers out there that can produce such decorations also for non stdcall calling convention. So this automagic trickery was removed from newer LabVIEW versions.
    I do think it could be considered a bug in the code that upgrades LabVIEW VIs, that it uses the calling convention that is configuerd in the dialog, instead of the calling convention earlier LabVIEW versions used automagically, but it is an esoteric corner case.
    What Compact Fieldpoint controller do you have? If it's anything newer than 20xx or 21xx forget it. The 22xx controllers use a PPC CPU and VxWorks operating system and can never get a Windows DLL to operate properly. If it is a 20xx controller it's still highly likely that DLL can not even get loaded into LabVIEW as it likely relies on other runtime libraries and possibly Win32 APIs not present in the Pharlap ETS runtime kernel used on those controllers.
    There is a tool to check a DLL for incompatible imports that are not present on specific ETS RT systems. And this list summarizes the RT system used on the various NI controllers.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Please teach me how to make the arrangement using Code Interface Node.

    How is what is necessary just to make arrangement (for example, Sine?Wave)
    using Code Interface Node? Please teach me a way.

    Try to get hold of the 'Advanced Analyis' library for labview. It contains VIs for doing FFT! No need to reinvent the wheel.
    If you can't get it and want to take the hard way, try to learn CIN programming by
    - reading the manual (no joke or cynism intended)
    - look for advice in NI's developer zone (www.ni.com/devzone) by using the search phrase 'CIN tutorial': you'll get several links which should be helpful in your case.
    - better than a CIN: try to use the DLL calling mechanisms and compile your C code into a dll. In order to learn dll intewrfacing for LabVIEW, follow the route explained under point 1 and 2 above...
    Good luck,
    Franz

  • CIN (Code interface node) LabVIEW runtime engine dependency

    Hello:
    Am I correct that the old style CIN (code interface node) is not dependent on what version of LabVIEW runtime engine is being used?
    However if I create a dll  from say LabVIEW 8.2 I must then alway have LabVIEW runtime 8.2 installed on any newer machine with newer version of LabVIEW?
    Thank You!

    GE Osmonics wrote:
    Hello:
    What I have are old CIN (no source) that work in LabVIEW7.1 but will not work in LabVIEW 2010 (link error, object code not loaded). 
    What I thought I could do is generate dll from the vi's that contain the CIN using LabVIEW 7.1 with application builder.
     I could use the Call Library Function from LabVIEW 2010 to load the 7.1 generated dll  to effectively do what the old CIN accomplished
    provided I installed the LabVIEW 7.1 runtime engine on my LabVIEW 2010 machine
    Thanks for the input
    If the CIN resource doesn't load you most likely changed the LabVIEW platform. LabVIEW for Windows 32 Bit and LabVIEW for Windows 64 Bit are different platforms. Just as LabVIEW for Windows and LabVIEW for Macintosh or Linux. A 32 Bit DLL, which a CIN is internally can't be executed in a 64 Bit environment at all.
    Your solution fails for more than one reason here. LabVIEW will try to load and link a LabVIEW DLL into its actual runtime environment to avoid interprocess communication latency which would be inavoidable if the DLL is started in a seperate runtime engine, which is in fact a new process. If your issue is 32 bit to 64 Bit you won't be able to link the 7.1 32 Bit DLL into your LabVIEW 64 Bit application through the Call Library Node at all.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • CIN(Code Interface Node)

    NI engineers:
    I am one of your users (labVIEW 6.1).
    Now, I have some questions to ask you. Please give me some help.
    I try to use the CIN(Code Interface Node) function, but I can not pass compile.I do not know why?
    The c file is very simple, and the Compiling result is as following.
    Please help me to solve the problem.
    Thank you !
    Chenyong
    2002/7/7
    * CIN source file
    #include "extcode.h"
    CIN MgErr CINRun(int a,int b,int c);
    CIN MgErr CINRun(int a,int b,int c) {
    /* ENTER YOUR CODE HERE */
    int a;int b;int c;
    a=1;b=2;
    c=a+b;
    return noErr;
    --------------------Configuration: try - Win32 Debug--------
    Compiling...
    629.c
    c:\labview\labview 6.1\z_beginner\629.c(17) : fatal error C1010: unexpected end of file while looking for precompiled header directive
    Error executing cl.exe.

    Hallo
    re-declaring the parameters as local variables will prevent the function to do what you expect.
    But your error is more probably a problem the compiler configuration. Make sure the path to the include file extcode.h (and all it's own includes) is known to your compiler.
    Gabi
    7.1 -- 2013
    CLA

  • How do I tie an Code Interface Node to the dos command prompt or Windows FTP stuff

    I have tried to use the System Exec.vi to do some ftp-ing with a box that If developing an automated ATP for. The sys exe vi dose most of what I need but not all. I can not modify the sys exe vi, nor can I copy the code interface node to another vi,I think that is because it has been compiled. So I need to generate my own vi that call the Windows ftp stuff or command prompt. I have spent several hours searching the NI site and the web in general and have not been able to find what to link the CIN to.
    Can somebody please explain this to me?
    I'm using:
    LabVIEW 8.6.0
    Windows XP Professional with service pack 3
    Thanks
    TeBlues

    Yes this is related to the post of yesterday. I tried your suggestions yesterday and was unable to get any of them to work.
    I down loaded the ftp library form OPENG and was unable to get it to connect to my box under test, and was unable to find any helping documentation on the OPENG site.
    I down loaded the vi from the earlier post you referred to and do to my lack of knowledge of windows was unable to figure out how the incorporate it in to my vi. For example what is the "lpsz Window?
    To complete this project I'm having to go deeper in to the stuff that goes on behind the seen than I have ever need before. So to me it looked like the next steep is to create a vi that used an CIN similar the the sys exe vi but add a few things around it..
    If this is wrong, What do you suggest? Keeping in mind I do not have the internet tool kit and the project dose not want to purchase it if we can avoided it.
    Thanks for your interest and time
    TeBlues

  • Code Interface Nodes and multithreading (openMP)

    Hi,
    We are experiencing a rather strange problem with the use of Code Interface Nodes (CIN) in LabView. The CINs are built with the Intel Compiler in the Visual Studio .NET 2003 IDE and use the openMP directives to easily implement multithreading. This does not seem to give any problems, as long as we do not declare our code threadsafe. If the code is declared threadsafe, everything runs smoothly but LabView crashes when the VI where the CIN is located is closed. If we do not declare the code threadsafe, there is no problem but our user interface is blocked during execution of the CIN. Since we are building an application for other users this is not acceptable.
    It clearly has to do with the multithreading, because forcing the compiler to create sequential code solves the problem. But off course we don't want to implement multithreading to disable it afterwards.
    We could switch to DLLs, but we are building an exe version which is under full development and can be updated by our users through the internet. Since CINs are part of the exe file itself and DLLs are not, we would like to keep it this way.
    We know this is a very specific problem, but we do not know if the problem is related to the multithreading in general or to the use of openMP in particular. Has anyone else tried multithreaded CINs and experienced any problems ? We basically just want to be able to stop the CIN from using our user interface, since we know everything is threadsafe.Message Edited by Raistlin on 05-07-2005 07:34 AM

    I have tried putting the vi in another execution system (standerd,other 1,other 2, ...) and the problem persists. I now built a DLL and have the same problem : marking it as reentrant makes the vi crash at closure, marking it as running in the UI does not give a problem. I now sent some code to Intel to check the thread safety, but I am quite certain there is no problem there.
    I found another thread where the problem was mentioned but also without an answer that could get me any further :
    http://forums.ni.com/ni/board/message?board.id=170&message.id=47264&requireLogin=FalseMessage Edited by Raistlin on 05-10-2005 02:04 AM

  • Code interface node - .lsb generated but does not load

    Howdy,
    i am using labview 6.1 and VC++/visual studio .NET 2003.
    i tried creating a simple code interface node to add two numbers. i followed the steps given in the "Using External Code in Labview" Manual. I made only one change, which is switching out "$(WkspDir)\$(OutDir)" (under custom build) with "$(ProjectDir)$(OutDir)" as the $(WkspDir) macro is missing from VC++.
    The build occurs successfully and i get a .lsb file. But when i ask the code interface node to load it up, it doesn't. The error description is, "Code Interface Node: object code not loaded."
    any suggestions? thanks in advance.

    Hi,
    This KB describes what may be the issue. I hope this is helpful.
    Regards,
    Ankita

  • Code interface node.

    I'm trying to determine if using the CIN and c code will increase the speed
    of some simulations that I'm doing. Does any one have some examples of how
    to do matrix operations or array operations in visual c++ version 6.0? Any
    help would be much appreciated.

    Yoichiro wrote:
    > How is what is necessary just to make arrangement (for example, Sine?Wave)
    > using Code Interface Node? Please teach me a way.
    Have you read the online documentation under "Search the LabVIEW
    Bookshelf" and there the selection "Using External Code in LabVIEW (PDF
    Only)"
    You need Acrobat Reader on the computer to read those informations but
    it explains basically anything you probably want to know about that.
    Now, why you want to create a CIN to generate a Sine Wave is another
    question. LabVIEW Full Development System and higher comes already with
    VIs to do that, and even if not it would be a lot easier to create a G
    code VI to generate a Sine Wave than it would be to generate a CIN even
    if you already knew how CINs are created.
    Rolf Kalbermatte
    r
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How do I identify the path and contents of a Code Interface Node

    I have an inherited a VI file that contains a CIN. If i double left click on the CIN icon nothing happens. Single right click and the menu options do not provide a way to identify the path/contents of the CIN. How can I found exactly what is going on inside the CIN and where has it come from ?

    To quote from "Using External Code in LabVIEW" :
    "LabVIEW loads your object code into memory and links the code to the
    current front panel or block diagram. After you save the VI, the file
    containing the object code does not need to be resident on the computer
    running LabVIEW for the VI to run."
    So, unless the source code is provided by the creator of the CIN, you're out of luck. It's the same thing with a third-party dll. Few vendors provide the source code for them either.

  • Compile time for code interface nodes

    How long does a CIN (for LabView 5.1) take to compile in Visual C++
    6.0 ?
    Thanks.
    Sent via Deja.com
    http://www.deja.com/

    [email protected] wrote:
    > How long does a CIN (for LabView 5.1) take to compile in Visual C++
    > 6.0 ?
    That depends almost entirely on the complexity of the code and the
    speed of the computer, but for most cases the extra overhead of compiling
    the CIN is much much less than the time taken to compile the code if
    it were a dll.
    Gavin Burnell, PhD Dept. Materials Science and Metallurgy
    Device Materials Group University of Cambridge, UK
    tel. +44 (0)1223 334375 FAX +44 (0) 1223 334373
    Gavin Burnell
    Condensed Matter Physics Group, University of Leeds, UK
    http://www.stoner.leeds.ac.uk/

  • I need to find a more complicate​d example, specifical​ly using arrays as inputs and outputs, to Code Interface Nodes.

    I am a beginner in C programming and I cannot understand how to use the structures that LabVIEW creates for its arrays in C. Can anyone point me to a good example?

    Check the following answer that I posted recently to a similar question.
    http://exchange.ni.com/servlet/ProcessRequest?RHIV​EID=101&RPAGEID=135&HOID=5065000000080000006D1E000​0
    Good luck!
    Vargas
    www.vartortech.com

  • Kill RT task frontpanel RED-X versus WIN32-API

    I have a LabVIEW task compiled to EXE which is downloaded to a remote processor; the front panel remains open locally.
    I want to kill that task and re-download it. This works the way I want if I use the local mouse to click the RED-X kill box on the upper right corner of the local front panel for the remote task... The panel disappears AND the remote task stops executing.
    The problem is that when I use the WIN32-API to try and kill the local front panel for the remote task I never get the remote task killed. Some  WIN32-API calls such as sending EndTask via USER32.DLL to the local panel's window ID cause the local panel to close but the remote task keeps running and is not aborted. Sending a WM_Close to the local panel's window ID involves the operator because it produces a LabVIEW dialog asking me whether I "want to close all RT tasks or not"
    What message do I send to the window, or what system call do I envoke to get the same result as that simple local mouse click on the RED-X kill box on the upper right corner of the local front panel for the remote task?
    Thanks, Jerry

    Hello.
    Normally a Real-Time task does not require a front panel so closing the Front Panel that you have opened remotely does not necessarily cause the VI to stop running, it merely disconnects the front panel connection to the VI.
    In order to achieve the same resul, you can use an Invoke Node to close another VI.
    To do this you will need to
    follow the steps outlined below.
    Open a blank VI and place an Open VI Reference on the block diagram.
    Create
    a control to the "VI Path" input of the Open VI Reference. On the front
    panel you will need to browse to the VI you want stopped.
    Wire an Invoke Node to the Open VI Reference and set the Invoke Node to "Abort VI."
    Wire a Close Reference to the Invoke Node.
    Wire a General Error Handler to the Close Reference.
    Open the VI that you want to stop. Make sure it is running and then run the vi you just created. This will stop the first VI.
    Hope this helps! 
    Kameralina
    Ask NI (ni.com/ask)
    Search The KnowledgeBase
    NI Developer Zone
    Measure It. Fix It. ni.com/greenengineering/
    NI Vision ni.com/vision/

  • LabVIEW call Win32 API DLL function from third party

    Hi everyone,
    I'm trying to build a LabVIEW 2010 interface on 32-bit Window XP system to configurate and communicate to an Anglient laser head through its USB expansion box. I contacted the vendor and they shared a win32 API with some dll files. I started with a function called "A55292Find", but the CLF node always pop up error 1097.I checked the MSDN to get the corresponding LabVIEW data type for CLF.
    My question is: Do I need to initialize those arguments? (How can I know the values of them if initialization is needed?)
    Could anyone help me figure out what's the problem?
    Here is what I have from API documents about this function:
    The A55292Find function returns lists of handles and board types for all the 55292 USB
    Expansion Modules connected to the system.
    A55292RC __cdecl A55292Find(
    HANDLE hBoxes[], // List of handles for the boxes found. (as Unsigned 32-bit integer numeric)
    BOARDTYPE PortABrdType[], // List of board types for slot A boards (as Unsigned 16-bit integer numeric)
    BOARDTYPE PortBBrdType[], // List of board types for slot B boards (as Unsigned 16-bit integer numeric)
    WORD *spMaxBoxes); // dimension for all of the passed arrays. (as Unsigned 16-bit integer array data pointer)
    // (function return type as Unsigned 32-bit integer numeric)
    Parameters
    HBoxes[] Array that will receive the list of HANDLES for all the 55292 boxes connected.
    PortABrdType[] An array that will receive Slot ‘A’ board type information for each 55292 box.
    PortBBrdType[] An array that will receive Slot ‘B’ board type information for each 55292 box.
    spMxBoxes Passes the maximum number of values that can be held in hBoxes, PortABrdType, and PortBBoardType arrays to the A55292Find routine and returns the actual number of boxes found
    The return value will be one of the following A55292RC return codes:
    Value Meaning
    A55292_NO_ERROR No error
    A55292_TIMEOUT Timeout accessing a shared memory
    Remarks
    This routine must be called to obtain handles and board type information used in calling all the other routines. If there are significantly more array elements than boxes, the routine will take longer to complete.
    These are the definitions: 
    typedef DWORD A55292RC; enum{A55292_NO_ERROR, A55292_HANDLE_ERROR,...}
    typeder WORD BOARDTYPE; enum{A55292_PCAL_BOARD, A55292_NO_BOARD, ...}
    Thanks a lot,
    Kang
    Solved!
    Go to Solution.
    Attachments:
    call A55292Find.vi ‏10 KB

    nkang11 wrote:
    Hi Mr. Kalbermatter,
    As you told me, I should try to use the defined enumeration words as control and indicator.
    For the previous CLF node, it successfully returned the hardware configuration (I have only connected a board at slot A):
    But I really want to see a string return as "A55292_PCAL_BOARD" which is defined by "typedef WORD BOARDTYPE; enumeration {...}; Does that mean I need to change the data type or do something like "converter"? Or initialize the array first, then convert it to string type?
    Right now, I'm trying to open the laser card by using "A55292PcalOpen(HANDLE hDev, SLOTSELECT SlotSelector);" function which requires to use the enumeration constants from " typedef WORD SLOTSELECT; enum {A55292_PORT_A, A55292_PORT_B};" but I'm confused to shot an constant control to a new CLF node.
    Since almost all of the arguments in dll function are typedefined as WORD, short and struct et al, I hope you could give me some hints on it.
    Thank you very much sincerely!
    Kang
    Depending on the actual C implementation you can simply create a LabVIEW enum with the according item names or use a ring control instead. Teh enum requires the numeric values of the items to be in consecutive order without any gaps in between. This is a given if the C definition never assigns a specific number to the item. If the C enum is not consecutive you need to go with a ring control instead.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • I am receiving this error message when trying to export pictures: 'Unable to Export": An internal error has occured: Win32 API error 2 ( "The system cannot find the file specified.") when calling ShellExecuteExW from AgWorkspace.shellExecute.// I have a H

    I am receiving this error message when trying to export pictures: 'Unable to Export": An internal error has occured: Win32 API error 2 ( "The system cannot find the file specified.") when calling ShellExecuteExW from AgWorkspace.shellExecute.// I have a HP ENVY Phoenix, fully loaded, 1 1/2 years old.

    Nevermind I fixed it. Thank you.

Maybe you are looking for

  • Outlook 2007 Calendar not syncing any more with Blackberry Bold

    I am looking for possible causes to a problem that started some time over the last 2 weeks. My BB has been running 4.6.0.162 (put out by Rogers, my provider) and I'm using the 4.6 Desktop Manager. Until then, whenever I'd sync my BB Bold with my Outl

  • View object that will allow to see data from two tables in a adf table

    Hi, I've been have serious issues to resolve this functional requirements with ADF. Basically I have two tables let say employee and department. A need a read only adf table to show the employees values but I don't want the users to see the departmen

  • ITunes stopped working while downloading an album

    Trying to download an album that I purchased.  I am told iTunes stopped  working, then the program shuts down.  I need help to access the store to finish my purchased album,

  • 802.1x EAP type not configured

    Hi, a simple 802.1x test with XP client sp2, 3560 with IOS 12.2(35)SE5 and ACS 4.1(1) build 23. EAP MD5 selected on the client and enabled on the ACS but I receive in ACS an authentication failure message, with Authen-Failure-Code "EAP type not confi

  • Need documents for sap scripts

    hi friends, I am fresh Abaper.I hav to study sap script . I need document which describes basic script coding procedure ie syntax. Thank u