GetDefaultPrinters (WinAPI call) crashes Labview

Hi all

For several reasons, I need to use the windows API to get the default printer. I know labview activex solutions, but those are not universal.

See attached VI. The winapi call blocking labview quite regularly. It works very well and correctly returns the default printer. However, some time later, a few seconds or a few surgeries later, he will break always labview. Why? I tried to change to "Run in the user interface thread" instead of any thread, but neither seems to help...

To get it to crash immediately, try to close the VI. This seems to do every time. Access violations...

He solved.

It's the definition according to msdn:

BOOL GetDefaultPrinter(
  _In_     LPTSTR pszBuffer,
  _Inout_  LPDWORD pcchBuffer
);

This buffer is large enough. Although I had assigned more sufficient in the CLN itself, I had to select "minimum size" for the pszBuffer to be pcchBuffer. Which solves the fracas. Don't know why it worked...

Tags: NI Software

Similar Questions

  • TCP opened briefly crashes LabVIEW

    Hello LabVIEW forum! Long time no see. I have been away doing other things but LabVIEW... I am back.

    Background:

    I'm working on a project where I need to make a TCP connection on a Windows 7 computer. The Windows machine will intentionally restart for each test. When it starts, I need make a TCP connection to a server that starts automatically on the Windows computer and send commands. While it is booting, I try to connect, get an error, try again, etc., until the connection is established.

    The problem:

    This computer name is not resolved by the DNS or the hosts file. If I try to connect using a host name and host name cannot be resolved, LabVIEW will freeze for a few seconds. If I click on the Red Quit button, I get the error not responding. He will eventually recover and gives me an error 54. The time-out period is not relevant in this situation. No matter how long or how short I put it in, it always crashes LabVIEW for about three to five seconds. If I try to connect by IP address instead, so I don't see this problem. If the machine is off, I just get a time-out error but LabVIEW does not freeze.

    I can't post code, but try this: write a VI with an infinite while loop and an indicator connected to the Terminal i and place a delay of 100 ms in it. That and note that the number increments. Now, create and run a second VI with the TCP inside open and use a machine name that does not exist. What I see is that the number in the first VI leave increment. I'm using LabVIEW 2014 32-bit on Windows 7 Ultimate 64 bit. First, open a console and try the ping command on the name that does not exist, you are trying to connect to and verify that it prints an ip number. Some providers Internet will solve all non-existent host names to an IP address they have for their benefit. If this is the case then you will not be able to reproduce this bug.

    I have a workaround (putting an entry in my hosts file), but I thought I would mention this possible bug. In addition, it gives me the opportunity to say hi to all my old friends on my favorite Ant! (the list is long but you know who you are)

    LabVIEW called Winsock for all network operations. Most of the Winsock operation is synchronous. This isn't a big problem for most code LabVIEW LabVIEW is multithreaded and performs the nodes in some thread the current VI is to. However, some features require access to a global data space and are protected by other means. It can be a global mutex and sometimes it is also solved by forcing the node to run always in the interface of LabVIEW user thread that also runs the message windows and Winsock loop hang in this message loop to do its own internal synchronous pseudo operations.

    IP address control is something you can try. It can also block because of the internal Winsock hanging in the application message loop, but maybe it will not be so that you can work around the problem. There is no way for a normal application using the Winsock API in order to avoid delays in internal Winsock for synchronous functions, and the resolutino address API supports asynchronous really not with variants.

  • DLL crashes LabView 2013 Pro, but good to EXE

    Hello

    I started having a problem older "degenerate." I had a previous post about a dll which plays a role of interface between a program running under Windows and LabView. The details are here:

    http://forums.NI.com/T5/LabVIEW/installed-program-no-Comm-with-driver/m-p/2659765/highlight/true#M79...

    Note that this isn't a double post, I just mentioned my recent problem there, when he was not that common.

    (http://forums.ni.com/t5/LabVIEW/installed-program-no-comm-with-driver/m-p/2662503/highlight/true#M79...

    Today - unknown reason - after a win system restart I can not run my development environment LabView code. When I run the main VI, it blocks all of the LabView environment during the first call of dll. This problem we had before also, but the 2nd of the 3rd test he ran OK. Today, I tried like 30 times, too many system restart. The native software spectroscope works very well too.

    Strange, if I run the exe to build, everything works fine. The problem appears only when I run LabVIEW. There is no error code, only a window appeared the first time, as I can send the error report to NOR. I can dig into some logs tomorrow at the lab, I just need to know where I can get.

    It seems that someone has also experienced similar behavior with external dll call:

    http://forums.NI.com/T5/LabVIEW/problem-DLL-crashes-LabVIEW/m-p/2562667/highlight/true#M773565

    "In the application resulting (Exe), it seems to work very well."

    What is the difference between when the dll is built in the exe file, and when it is executed from the LabView dev environment?

    Thanks for any idea and help!

    (if nothing helps, I just re - build the exe after changes to the program, but it slows down some coding)

    The last time, we have no comments from the company that created this dll, I'll try to contact again...)

    Hello

    you said that you have read the discussion in the following link:

    http://forums.NI.com/T5/LabVIEW/problem-DLL-crashes-LabVIEW/m-p/2562667/highlight/true#M773565

    Are you facing exactly the same problem?

    If Yes, then there is not much we can do. LV is an access contradication with your included DLL unless you have access to its source. You do not experience these problems with the exe since that only works on the run-time engine while the LV environment executes the code in a different way (why LV reserve this special memory on which your DLL is also trying to access.

  • TestStand do not call a Labview DLL copied to a new location.

    TestStand v4.2 & v8.6.1 LabVIEW: I have a problem with TestStand calling a Labview project DLL. It will call the DLL successfully if it points its record source (the directory where the DLL was built. However if the DLL is copied to the clients working directory and the appellant TestStand step points to the copied DLL, the problem occurs. The TestStand calls the DLL from the working directory of the client, but does not execute the DLL, simply set the status of the step to "Done" where he clearly didn't.

    The vi named in the DLL has correctly, all handles error clusters such that if there is an error in the vi running, the error would be forwarded to TestStand.

    Any ideas please?

    Update: the original problem was never solved, but another method was used successfully to generate an Excel results worksheet. This used controls Active-X to open a file, import a model, write the data, close the file, and then make the new file read-only. It now everything works fine.

  • BUG: Date/Time Format string with %D in the format string crashes LabVIEW

    Do %D in the format string 'Format string DateTime' blocks LabVIEW 2009 SP1, as shown in this code snippet.  Should I use instead of %D %d but an incorrect format string should not crash LabVIEW.

    Fixed in 2010.

  • error message when you try to remove the software from Add/Remove: not managed by exception DLLfunction call crashed

    I'm trying to uninstall Franklin Covey for Outlook.  The program will uninstall not because of the "unhandled exception" FUNCTION DLL CALL CRASHED: fpoInstall_FPOInstall _GetPST file.

    the program is still listed in Add/Remove programs? If Yes, go to cnet.com and download and install revo uninstaller. It's actually better than the regular add/remove path. Revo examines the entire hard drive for that this presence of programs and removes even the registry entries.

  • can not find size_t during import a dll and calling a labview crash function

    Hello, experts

    I need to use FingerLakeInstrument DLL (see attachment) within Labview for talking to a CCD camera. It is built from microsoft visual studio C++

    I unzip FLI dll in my D:\proj\...\linfli-32 and import the dll from there. created a c:\FLIDBG.txt FLI dll must write the debug message on it if are called the FLISetDebugLevel() or others.

    During the import of the dll, the first thing I got is (IE size_t) could not be found. I installed the free version of microsoft visual studio C++

    but can not find 'typedef unsigned int size_t;

    in the end, I just added

    typedef unsigned int size_t;

    in the libfli.h. Having done this, I am able to import all the functions in Labview and have a library of user called libfli.

    However, as soon as I start to call a simple function in a test.vi, as FLIGetLibVersion (char * worm, size_t len), which consists of nothing else the library, the labview crash.

    I created a simple C test.exe who calls a lot of functions with no problems

    any suggstion?

    concerning

    Xiaofeng

    You don't have not shown us how the LabVIEW code looks like. The size_t setting refers to the length of the buffer, in that you spend. In this case you pass a string. So, presumably, you created a buffer zone in LabVIEW to a string of sufficient size, and set the parameter "len" to the length of this string. You also have to make sure you use the correct calling convention?

  • Get the 1097 error when trying to call a Labview DLL

    I had to write a wrapper DLL to use some functions in the DLL to a third party, and I'm having a few problems. I created an executable to test my code and it works fine, but when I try to execute the same function in the DLL that I created in Labview, I get error 1097. I read through most of the posts on this forum about this issue, but none of the proposed solutions are working for me. I'm sure this isn't a question of transfer settings to COLD LAKE because I changed the function so it only accepts a single entry (a number he obtains from a Subvi, which came from the third-party DLL, this entry is working with a bunch of other functions, so I don't think that is the question).

    I have attached the C code that creates the wrapper, but I don't know how it is useful without familiarity with the functions of the original DLL. I hope that someone can spot something basic I am out of my code, but please let me know if I need to call something else.

    I use a Labview 32 bit version 2012 on a 64-bit Windows 7 computer.

    Thanks in advance for any help!

    You should read the documentation on LoadLibrary() and understand. Essentially if you provide a full path to LoadLibrary() the DLL MUST be present at this place so that LoadLibrary() will succeed. If you pass only the name Windows DLL will ONLY search in these places:

    (1) if the module (the DLL) is already loaded it will return a handle to the loaded module and increment its reference count

    (2) if the referencing module contains a manifest (either incorporated into the image module or in a separate manifest file in the same directory as the executablemodule) specyfying a version number for this DLL will load this DLL with this version of the SxS (side by side) location and failure if it is not present

    (3) if the executable load contains a manifest (either incorporated in the executable file or in a separate manifest file in the same directory as the executable file) number specyfying a version for this DLL, it will load this DLL with this version of the location of SxS (side by side) and fail if it is not present

    (4) it will search for the DLL in the same directory as the directory where the current image of the process is loaded. It is NOT the directory of the DLL loading the DLL, BUT the directory where the EXE file from which the process was created.

    (5) in the system directory

    (6) in the Windows directory

    (7) any directory in the PATH environment variable

    (8) the path of current directory which is a location managed by windows by process and changed the two explicitedly when the application calls the API SetCurrentDirectory() but also implicitedly by things like the file selection dialog whenever it is rejected by other means than the undo operation.

    Essentially putting your dependend DLL in the same directory as the wrapper DLL does NOT work when you use the name of the DLL only UNLESS you place the two DLLs in the same directory as your executable file. If you don't want this restriction and want to be able to move these modules together in different directories, you don't have to create the correct path in your wrapper to LoadLibrary(). Basically, you must have the code to determine the location of your DLL wrapper path and then strip her own name and add the DLL name wrapped in it and then move to the LoadLibrary().

    There are several ways to determine the path of the current module. The simplest if you don't mind having the name hard-coded in your code DLL would be to ask GetModuleFileName (GetModuleHandle ("yourDLLname"), buffer, size).

  • How to check if the exe called by labview does not respond?

    Hi all

    Here's the situation:

    I have a main executable VI which calls on several other screws which are all in the form of exe.  Sometimes, when these other .exe are called, they open reduced as they are supposed to, but they begin the desired process because they become inadmissible.

    Basically, I wonder if there is a way to check if a window responds or not.  I'm using LabVIEW 2010 on a computer with Windows 7.  All the subVIs called by this VI have this problem but to different degrees.

    I thought that I might be able to do this through a reference application and research somehow the title of the window for "(ne répond pas) ', but I have not found a way to implement it."

    Thank you

    M

    I sometimes use a library of 3rd party called AutoIT to do things like move windows and check names, window titles.  Related download installs an ActiveX control that allows you to do.

    See here for a list of the supported control functions.  Look at the end (all functions starting with "Win").

  • TestStand call using LabVIEW VI

    Hello

    How to call teststand through LabVIEW and LabVIEW indicator of day?

    the two should operate in parallel and for this VI I spend only a sequence file path. (except UI example suggest me other examples)

    Best regards

    Usually you have a UI call TestStand.  The user interface can be built in LabVIEW.  Here is the document on the development of the user interface:

    http://www.NI.com/white-paper/7560/en/

    Then you use the Messages of the user interface to communicate back and forth between the user interface and your movie file.

    http://www.NI.com/Tutorial/4532/en/

    Hope this helps,

  • Creation of Data Type when the script crashes LabVIEW

    When you use the script (LV2010) if I call the Create method of Data Type (available appeal node when a reference to the BD is cable), if I have all but 1 up to the wiring on 'style' terminal, LabVIEW, it blocks. LabVIEW then restarts with an error message saying that "the last time that you have run LabVIEW internal error or accident took place in lvmain.cpp, line 1756. If I have wiring 1 However, it creates a constant fine.

    I see in the context-sensitive help that it always creates a control at the start, but it seems that I can't get it to create a constant. So, okay, I decided to go around, create the constant, take the new object refnum he returned and there to change the constant in one control... but I can't get this work. Can someone point me in the right direction? Here is the code and the screenshot; This is a quick drop plugin.

    It is intended to run on a cluster that is perceived as an icon if you want to test, you need to create that.

    I presented the 'style' value, 0 if if you don't want to plant LabVIEW, set it up to 1.

    No time for an in-depth exploration now.  Create from Datatype killed my LV10.  What I was able to do after creating a constant of cluster, the consultation as an icon and select it.  (1) with the scripts, create a new VI and stick that the constant to figure (2) mount the pasted objected to the ClusterConstant and the change of control.

    I think I know where you're going, should be interesting.

  • From the telnet session between calls of LabVIEW, TestStand

    TestStand, I'll call telnet.llb VI.

    In a step TestStand am opening a telnet session to IP address and the collection of the telnet (U32) connection. In the next step of TestStand, I pass the telnet connection to a telnet writing VI, but this error occurs.

    "Dequeue item to acquire Semaphore.vi:1-> Write.vi:1-> Telnet Write.vi.ProxyCaller Telnet"

    The telnet open, write, read and close the excellent work if I get the number of telnet in the same VI session. But I need to keep the session open between TestStand calls because a huge VI is not possible.

    Thank you

    Josh

    Verify that your adapter for LabVIEW has reserved the execution. If it is already, I don't know, you may need to create a parallel thread that keeps the session active.

    CC

  • Sharing of Variable crashing LabVIEW

    It's just one of those projects that has a wall of brick in each round so far. Two computers running LV2009. Computer A hosted data write sharing Variable. Computer B shared reading Variable data hosts. Reading data is linked to write data. Everything worked fine, and then yesterday afternoon, I don't think I changed anything on the shared variable, I start my VI on the computer B and LV crashes. The VI begins to run before the first performance for reading data, and then poof, everything open in LV disappears. Since then the problem is reproducible 100 percent.

    Here's what I know:

    1. an error indicator hooked to reading data watch-1950679034 (shared Variable has no value) for about a second before the accident. Everything stops execution as soon as the warning.

    2. writing of data is a single editor, but it is also sometimes read in VI it is written in. It is not read when the accident occurred. I can however perform playback on computer A without incident.

    3. don't know if this is related, but if I open the VI on computer B and then open the project, I am not able to drag data reading of the project on the block diagram. I also cannot perform operations on the shared Variable (as right-clicking, ignore the timestamp). I have to close the VI and reopen the project. In retrospect, this problem might have started when I opened the VI without opening the project.

    I'm torn between abandoning the shared Variables and try to understand it. I would definetely prefer to use the Variable shared, mainly because I need a buffering. I guess I can put other things buffer. Don't know if I can remote access to a queue, or...?

    I was able to reproduce the crash that you see with extreme simplicity VI in LabVIEW 2009.  This looks like a bug in LabVIEW, so I'll check if there is any of this behavior already.

  • call of LabView VB6 DLLs

    Hello

    I have a dll written in VB6 to control some 3rd party hardware

    I already tried to use the node of the library function call but it doesn't seem to work, after that also, I tried to use

    RefNum Automation, entry and select ActiveX class and and locate my DLL but when I select the dll, the following message shows on the screen: the selected file is not a .NET, type library or executable automation assembly.

    Keep on the issue, I tried to save the Visual Basic DLL on the system through the REGSVR32 command but I got another different message (fbidio.dll was loaded, but the DIRegisterServer entry point was not found. This file can not be registered). Looks like the dll that I intend to use is very old.

    Can someone guide me on this issue, what other things I can try.

    Thank you.

    Concerning

    Hello

    The LabView collapse when I try to use the node library call, in my understanding, based on some comments I've seen, it is not possible to use the call library node for the VB dll.

    Anyway I already understood how to control my gear, I found a module update for Active X controls in the web for my hardware and now my application works perfectly with an ActiveX container, then insert the ActiveX object.

    Tounsiiaa so.

    Concerning

  • East - viable to preduce a cyapi.lib dll that is cmpiled by c ++ that can called by labview?

    Now I'm tring to make a dll with cyapi.lib, so labview can call the function for conneting usb device (cy68013 produced by Cypress company), but I'm not sure that this way is viable.
    This my simple code to translate cyapi.lib to cyapi.dll:
    #include "typedef.h".
    #include "CyAPI.h".
    #pragma comment(lib,"CyAPI.lib")

    extern bool _declspec (dllexport) Open_0 (void);

    CCyUSBDevice * USBDevice = new CCyUSBDevice();

    bool Open_0()
    {

    return USBDevice-> Open (0);   get a funtion that can open device 0
    }
    the link error is the following:
    The compilation...
    CyAPI.cpp
    Which connects...
    Creating object Debug/MainDLL.exp and library Debug/MainDLL.lib
    CyAPI.lib (CyAPI.obj): error LNK2001: unresolved external symbol ___security_cookie
    CyAPI.lib (CyAPI.obj): error LNK2001: unresolved external symbol symbol @__security_check_cookie@4
    CyAPI.lib (CyAPI.obj): error LNK2001: symbol ___CxxFrameHandler3 unresolved external
    CyAPI.lib (CyAPI.obj): error LNK2001: symbol __EH_epilog3 unresolved external
    CyAPI.lib (CyAPI.obj): error LNK2001: symbol __EH_prolog3 unresolved external
    CyAPI.lib (CyAPI.obj): error LNK2001: symbol __EH_epilog3_GS unresolved external
    CyAPI.lib (CyAPI.obj): error LNK2001: symbol __EH_prolog3_GS unresolved external

    I think maybe the reason is Ihaven can't initialize all the variable used in the cyapi.lib or there is something wrong in VC development environment.

    Can someone help me?

    If it is compiled with c#, then it is a .NET assembly. To use it, you simply use the .NET features in LabVIEW. You should have received a few examples of programs with it. Essentially, you need to do the same thing that made the example program, but you use LabVIEW .NET to do. There is with LabVIEW provided examples on how to use .NET. In most cases, it is easier to use than to try to call a DLL 'normal '.

Maybe you are looking for

  • How can I add trusted sites in the internet options?

    I have to add my school as a 'trusted site' sites so I can access my student portal. You can do it easily on internet explore by going to tools, internet options, trusted sites. However, bc I have Windows 8, I have to go through firefox. Help!

  • Qosmio F60 - 12F: Alsaconf said: this audio device was not all controls

    said alsaconf "sound device is not all controls. 00:1 b. 0 Audio device: Intel Corporation 5 Series/3400 Series Chipset Audio high definition (rev 06)Subsystem: Toshiba America Information Systems device 0001Flags: bus master, fast devsel, latency 0,

  • HP Elitebook 840 G1: Re: resetting the BIOS password

    I've updated the bios of my laptop Elitebook 1 840 and don't remember the password. [personal information]Thank you very much

  • Build tables then again

    Hi all I know that you are reading these words a lot here, sorry, I'm new to labview and I want someone to help me in vi that I'll explain now. I have a while loop with a variable inside (local variable or a random variable in this example), the loop

  • sky no longer works with windows 8.1

    Hello, my sky management software no longer works and tells me error: camconfig.cpp 507 What do I do Thank you