How to use Labview 6 to call OpenPrinter()

I would like to use Labview 6.0.2 to call API winspool.drv function OpenPrinter().

[email protected] wrote:
Thanks for your help, but I had already tried the steps you suggested. The OpenPrinter() function takes two input parameters: one is the printer name, the other parameter the printer defaults with its type of data as structure in C, which is equivelent to  the data type of cluster in Labview. The only output parameter from this function shall return a handle of the printer, but when I used the labview node to call this function, the output variable returns zero, which means the function call is not working. I suspected the cause is probably due to that I did not correctly pass the second input parameter to the function. I will really appreciate if you could take time to try to run your code to see if you could get it to work.
This is not trivial.
The function prototype is
BOOL WINAPI OpenPrinterA(LPSTR lpPrinterName,HANDLE *phPrinter, LPPRINTER_DEFAULTSA pDefault);
The second parameter would be no problem you just treat it as a pointer to an uInt32 but the third is a pain. Its structure definition is:
typedef struct _PRINTER_DEFAULTSA {
  LPSTR        pDatatype;
  LPDEVMODEA pDevMode;
  ACCESS_MASK  DesiredAccess;
} PRINTER_DEFAULTSA, *LPPRINTER_DEFAULTSA;
with all but the ACCESS_MASK parameter being a pointer to some memory. You could pass in a NULL for this parameter in which case certain defaults will be assumed and you could theoretically change them later on by calling SetJob().
But here comes the crux of this: Using the returned printer handle for anything (with or without having specified a valid defaults structure) will require you to call many more Windows API functions, and some of them are even more complex than this one. All in all if you really need to do something by opening the Printer Driver in winspool.drv, it is a much better idea to implement that in an external DLL written in C with a LabVIEW friendly  calling interface and import that into your LabVIEW application instead.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions

Similar Messages

  • I need to program a Hittite Fractional​-N Synthesize​r Evaluation Kit with a HMC702LP6C​E an external YIG oscillator​. Not sure how to use Labview to control the PLL.

    I need to program a Hittite Fractional-N Synthesizer Evaluation Kit with a HMC702LP6CE an external YIG oscillator.  Not sure how to use Labview to control the PLL.

    Here is how to use the PLL. But I don't know of how to interact with that device
    http://zone.ni.com/devzone/cda/tut/p/id/3781
    And for thouse who don't know what a PLL is a free bonus link is here:
    http://digital.ni.com/public.nsf/allkb/07BC8D77D4E​9AE258625708B007CE74F?OpenDocument
    and a second one on what that device is: http://www.hittite.com/products/view.html/view/HMC​702LP6CE
    Now we are all caught up to speed.
    Sam S
    Applications Engineer
    National Instruments

  • How to use labview with the handyboard

    Hi,
    how to use labview with the handyboard
    Thx...

    I'm assuming you're talking about this, since you didn't provide a link for those of us who don't know what you're talking about.
    As the other poster said, you didn't say how you want to use LabVIEW with it.  If you want to write LabVIEW programs than run on the microprocessor, then you're out of luck.  If you want LabVIEW to interact with it, then you've got a couple of options, SPI probably being the best, but it also has DI and AI that you could use to communicate with it - the DI's could be used as a parallel interface.
    Message Edited by Matthew Kelton on 12-17-2007 02:21 PM

  • How to use labview with gpib to connect with Agilent PNA E8362B ?i am newbie ..just started to work on labview about a fortnite bck and a novice in interfacing skill ..so plzzzzz explain me in a litle detail

    how to use labview with gpib to connect with Agilent PNA E8362B ?i am newbie ..just started to work on labview about a fortnite bck and +i am a novice in interfacing(networking... jst know tidbits) skill ..so plzzzzz explain me in a litle detail

    Sir
    We were able to solve that problem...but now could you advice as to which DC power supply we should use (preferably avalable in India) so that it can be controlled by Labview (through a gpib/rs232/any other port) to give a square wave of desired frequency/other parameters.
    Regards
    Shivam

  • How to use labview with gpib to connect with Agilent PNA E8362B ?

    how to use labview with gpib to connect with Agilent PNA E8362B ?i am newbie ..just started to work on labview about a fortnite bck and +i am a novice in interfacing(networking... jst know tidbits) skill ..so plzzzzz explain me in a litle detail

    Duplicate Post.

  • How to Use LABVIEW charts with Mathscript

    Hi,
       I recently tried to work on Mathscript and it is really amazing. what I tried to figure out is:
        Instead of plotting using traditional "plot" statement, how to use LabVIEW chart ( I know how to Add output but the graph were not as expected
    Is there any mean to get rid of this "Lengthy" delay that "ALL MATLAB User know" for first time compilation?
    Thanks in advance
    Waleed El-Badry MSc.,MCPD, ISTQB Certified Tester
    Assistant Lecturer
    Mechatronics Department
    Faculty of Engineering
    Misr University for Science & Technology

    Well Chris,
             I was about to post the solution, but as I said, I'm in a middle of experts
    It took me 3 hours to figure it out. I should've checked your answer . I resolved to the same suggesstion of yours. I only added some functionality to get the newbies like me being acquainting with how easy to work with LABVIEW mathscript based on MATLAB knowledge.
    Waleed El-Badry MSc.,MCPD, ISTQB Certified Tester
    Assistant Lecturer
    Mechatronics Department
    Faculty of Engineering
    Misr University for Science & Technology
    Attachments:
    Play with Mathscript.vi ‏35 KB

  • How to use LabView to control Primera Bravo II CD burner?

    I am trying to use LabView to control the Primera Bravo II CD burner and label printer. The software that controls the Bravo II is PTPublisher. How to use LabView to communicate/control the PTPublisher? Please help, Thanks

    Hi Qian,
    I installed PTPublisher on a virtual machine, and I was wondering what kind of tasks you wanted to control within LabVIEW.  From the program GUI, it appears like the only way to access functions is via mouse clicks.  Do you know of any other way to control the Bravo II CD burner besides the PTPublisher software?  If not, does the PTPublisher allow you to control it in some way other than clicking?
    Peter K.
    National Instruments

  • How to use LABVIEW to collect wireless network camera (with video server) video.

    How to use LABVIEW to collect wireless network camera (with video server) video.I would like to use LABVIEW for a wireless network camera (IP Camera comes with the video server module)the client program.Will the ability to achieve?If feasible, how to do, there are examples, thank you.

    I believe NI Vision is what you are looking for. 

  • "HOW to use Labview call Dll compiled by VC++"

    "hello,I use VC++ compile a DLL,and i want to call DLL Function in LABVIEW program.But there is a dll function
    when i call it in labview.There is error.The prototype of Dll Function that make error is "USHORT DLLFUN __stdcall IBWRT(unsigned short dev_address,const char *pstrWrite)",The second paramenter is a char pointer,
    and the paramenter pass a command which content is
    "MEASURE:CURRENTC? 1A,0.001MA".
    When i use VC++ to call this function,i program followed:
    CString m_wrt;
    int ReturnW;
    m_wrt="MEASURE:CURRENTC? 1A,0.001MA";
    char buffer[40];
    strcpy(buffer,m_wrt);
    ReturnW=IBWRT(4,buffer);
    and this call is correct.
    But when i use labview to call this function.ther
    e is
    error.So, who can help me,to tell me how to call this
    function.Thanks."

    Are you asking about porting code or calling C++ code in LabVIEW?  As far as porting code, there's no easy way to move code back and forth between LabVIEW and C++.  However, if you are trying to call C++ code in LabVIEW, you can compile it as a DLL and call it in LabVIEW using the Call Library Function node.
    Chad B. » National Instruments » ni.com

  • How to use Labview 7.0 to make program interface?

    Hellow!
    Will Labview 7.0 be able to make the program interface? just like some application software made by VC++,VB?
    The program interface should have the menu,button,...
    Thanks!

    You can use LV to create a fully working program with an interface of your design, just like you would in any other compiler. LV actually serves as a compiler for a graphical language called G, which is based on dataflow instead of text based execution (the data "flows" through wires from one function to the next, controlling execution order and filling the role of variables).
    Since LV is multiplatform (and not MS), its default controls are not identical to those in VC and VB, but those can be accessed to. Actually, in many ways, it's much easier to build an interface in LV, because building the interface actually defines your "variables" and your interaction with the code.
    An interface would be no good without a program, so you will have to know how to use LV. It's much faster to learn than other languages, but you will still need some experience to write good programs.
    To learn more, I suggest you start by reading the LabVIEW user manual. Also, try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
    In addition, I suggest you read the LabVIEW style guide.
    If your question was only about MS buttons, like in VB and VC, you can find them in the Dialog Controls palette, or you can use ActiveX to embed them into your program.
    Try to take over the world!

  • How to use labview to control a robotic arm by EMG signal

    Hello,
    I am working on simulation of an active Exoskeleton (wearable robot) for the upper limb using LabVIEW for my senior project. I need to use the EMG signal as an input to move the elbow joint (flexing and extending). I downloaded labview biomedical toolkit to take a ready simulated EMG signal but have a weak experience in LabVIEW.
    The design criterial I am planning to use is to establish a threshold for the EMG signal using a comparator (above 0 for example) and set a counter for everytime the signal passes the threshold as(+1) in every count. Then, specify a degree value for the counter (for example when the counter reaches 10000) and feed this value of the counter to a simple simulated structure for the joint (simple angle of 2 lines) or a meter to represent the movement.. e.g. every 10000 count = 1 degree of movement. Zero crossing can also be used instead of the comparator and the signal will be filtered and that is easy to do. However, my problem is in converting this logic into LabVIEW. I don’t know how to set a counter for the signal and make every number of counts refer to a specific degree of movement and I also don’t know how to form the simulated joint structure in LabVIEW or even how to transfer this into a simple meter device in LabVIEW.
    I have only one month to do this project so any help or ideas you provide are highly appreciated
    Thank you ,

    CarlFHellwig 
    Thank you for providing this example I just implement  it in the software to check the counter results.
    In fact, the design criteria I desided to use latly is to use is to establish a threshold for the EMG signal using a comparator and correlate the EMG signal with the angles of movement of a simple simulated structure "motor" for a single joint (simple angle of 2 lines) eg. 30,60,90,120,150 degrees for flexing and extending. Zero crossing can also be used instead of the comparator and the signal will be filtered and that is easy to do. 
    In other words, the idea is to drive a motor for different angles based on the input EMG signals. I am now stuck with developing the algorithm of how the angles are related to the RMS value of the signal while flexing and extending and how to convert this RMS into angular velocity and angular position to form the simulation. 
    I will be grateful if someone guided me to a person did a similar project to discuss some issues. 
     

  • Is there any one knows how to use labview 6.0 to make a "continue" function like the one in C language?

    I am using labview 6.0 and i like to know is there any one knows how to stop the current iteration in while loop or for loop and continue to do the next iteration,just like the "continue" statement in C or C++ language?

    Simple test here in LV6 confims that you can't do this. Not in a useful
    sense anyway. "Stop" doesn't stop execution simply of the current VI, it
    also kills all VIs above it. It would hence be difficult to argue that this
    approach is in any way similar to "continue".
    What version of Labview have you tested this on and can you post a
    demonstration?
    Craig Graham
    Physicist/Labview Programmer
    Lancaster University, UK
    "Oleg" wrote in message
    news:506500000005000000E45B0000-1011517314000@exch​ange.ni.com...
    > Hi,
    > you can orginize all the inner actions of your while loop into the
    > SubVI. Then use the Functios/Application Control/Stop.vi in this SubVI
    > to stop the current interation in any point you want. This will stop
    > your SubVI and yo
    u will automatically goto the next iteration in your
    > while loop.

  • Need Expert's Advice - How to use LabView Efficiently and to increase Readability

    My application is fairly complex. It is a real world testing applications that simultaneously controls 16 servo motors running various stress testing routines asynchronously and all at the same time. The application includes queues, state machines, sub VI's, dynamically launched VI's, subpanels, semaphores, XML files, ini files, global variables, shared variables, physical analog and digital interfaces and industrial networking. Just about every technique and trick that LabView 2010 has to offer and the kitchen sink as well.
    Still I am not happy with the productivity that LabVIEW 2010 has provided, nor the readability of my final product.
    Sometimes there are too many wires. Much of my state machines have a dozen or more wires just going from input to output, doing nothing, just because one or two states in the machine need that variable in some state. Yeah, I could spend alot of time bundling and unbundling and rebundling those values, but I don't think that would improve things much.
    We have had a long discussion about the use or misuse of Local variables in this forum and I don't want to repeat that here. I use them sparingly where I think it is relatively safe to do so. I also have a bug whenever I try and copy some code that contains one or more local variables. On Pasting the code with local variables, the result is something other than what I expected, I am not sure what. I have to undo the paste and rebuild the code one object at a time.
    I am also having trouble using trouble using Variable Property Nodes. When I cut and paste them, they often loose their reference object and I have to go back into the code and redo the Link To on each one. That wastes alot of time and effort.
    Creating subVIs is often not appropriate when the code makes many references to objects on the Front Panel. Some simple code will turn into a bunch of object references and dereferences which also tends to take alot of work to clean up and often does not help overall readability in many cases. I use subVIs when appropriate, but because of the interface overhead, not as often as I would like to. My application already has over 150 sub VIs.
    The LabView Clean Up Diagram function often works poorly. It leaves way too much empty space between objects, making my diagrams 3 to 4 24" screens wide. That is way too much and difficult to navigate effectively. The Clean Up function puts objects in strange places relative to other objects used nearby. It does a poor job routing wires and often makes deciphering diagrams more difficult rather than easier.
    My troubleshooting strategies don't work well for large diagrams and complex applications. The diagrams are so complex that execution highlighting may take 20 minutes for a single pass. Probes help, but breakpoint aren't of much use, because single stepping afterwards often takes you to somewhere else in the same diagram. I can't follow the logic well doing this.
    Using structures, I may have Case structures nested 5 to 10 levels deep inside some Event Structure inside a While Loop. Difficult to work with and not very readable.
    All and all, I can make it work, but I am not happy about the end result.
    I am hoping to benefit from some expert advice from those that are experienced in producing large complex applications efficiently, debugging efficiently and producing readable diagrams that they are proud of.
    Can anyone offer their advice on how best to use the LabView features to achieve these results in complex applications? I hope that you can help show me the light.

    I'm not an expert but I'm charged out as one at work.
    I am off today so I'll share some thoughts that may help or possibly inspire others to chime. I have tried to continually improve my code in those areas and would greatly welcome others sharing their approaches and insights.
    Note:
    I do refactoring services to help customers with this situation. What I will write does not represent what we do in a code review since our final delverable is a complete final design and that is beyond the scope of this reply.
    I'll comment on your points.
    dbaechtel wrote:
    My application is fairly complex. ...
    While watching Olympic figure skating competion slow-motion replays, I learned how the subtleties of how the launching skate is planted while entering a jump can make the difference between a good jump and a bad one.
    In software, we plant our foot when we turn from the design to the development. I have to admit that there where a couple of times when I moved from design to development too early and found myself in a situation like you have described.
    How to know when design is done?
    Waterfall says "cross every 't' and dot every 'i' " while Agile says "code now worry about design latter" and Bottom-up "says "demo working why bother designing" (Please feel free to coment on these over-simplifications gang).
    My answer is not much more helpful for those new to LabVIEW. 
    My design work is done when my design diagrams are more complicated than the LabVIEW diagrm they describe.
    dbaechtel wrote:
     simultaneously controls 16 servo motors running various stress testing routines asynchronously and all at the same time. The application includes ...and the kitchen sink as well.
    Have you posted any design documents you have? These will help greatly in letting us understand your application. More on diagrams latter.
    Anytime I see multiple "variations on a theme", I think LVOOP (LabVIEW OOP ) . I'll spare you the LVOOP sales pitch but will testify that once you get your first class cloned off and running as a sibling (or child) you'll appreciate how nice it is to be able to use LVOOP.
    Discalimer:
    If you don't already have an OOP frame of mind, the learning curve will be steep.
    dbaechtel wrote:
    Still I am not happy with the productivity that LabVIEW 2010 has provided, nor the readability of my final product.
    Sometimes there are too many wires....going from input to output, doing nothing,... spend alot of time bundling and unbundling and rebundling those values, but I don't think that would improve things much.
     Full disclaimer:
    I used to be of the same opinion and even used performance arguements to make my point. I have since, changed my mind.
    Let me illustrate (hopefully). This link (if it works for you, use lefthand pane to navigate hierachy) shows an app I wrote from about 10 years ago when I was in my early days of routing wires. Even the "Main" VI started to suffer from too many wires as this preview from that links shows.
    Clustering related data values using Type Definitions   is the first method I would would urge. This makes it easier to find the VIs that use the Type def via the browse relationships>>>callers. If I implement my code correctly, any problem I believe is associated with a particualr piece of data that is a Type def has to be in one of the VIs that use that type def therefore easier to maintain.
    When I wrote "related data" I am refering data normalization rules (which my wife knows and I picked-up from her and I claim no expertise in this area) where only values that are used together are grouped. E.G. Cluster named File contains "Path" and "Refnum" but not "PhaseOfMoon". This works out nicely with first creating sub-VI since all of the data related to file operations are right there whe I need it and it leads into the next concept ...
    When I look at a value in a shift register on the diagram taking up space that is only used in a small sub-set of states, I concider using an Action Engine . This moves the wire from the current diagram into the Action Engine (AE), and cleans up the diagram. The AE brings with it built-in protection so provided I keep all of the opearations related to the the Type def inside the AE I am protected when I start using multiple threads that need at that data (trust me, it may not make a difference now but end users are clever). So that extra wire is effective encapsualted and abstracted away from the diagram you are looking at.
    But I said earlier that I would not sell LVOOP so I'll show you what LVOOP based LV apps look like to contrast what I was doing ten years ago in that earlier link. This is what the top level VI looks like.
     And this is the Analysis mode of that app.
    I suspose I should not mention that LVOOP has wizards that automatically create the sub-VI (accessors) that bundle/unbundle the clusters, should I?
    Continuing...
    dbaechtel wrote:
    We have had a long discussion about the use or misuse of Local variables...I also have a bug whenever I try and copy some code...
    If you can simplify the code and duplicat ethe bug. please do so. We can get it logged and fixed.
    dbaechtel wrote:
    I am also having trouble using trouble using Variable Property Nodes....
    That sounds like a usage issue. Posting code to illustrate the process will et us take a shot at figuring out what is happening. 
     dbaechtel wrote:
    Creating subVIs is often not appropriate... My application already has over 150 sub VIs.
    "Back in the day..." LV would not even try to create a sub-VI that involved controls/indicators. I use sub-VIs to maintain a common GUI often but I do it on purpose and when I find myself creating a sub-VI that involves a control/indicator, I hit ctrl-z immediately! 
    I figure a way around it (AE ?) and then do the sub-VI.
    Judging by your brief explanation and assuming you do a LVOOP implementation, I would estimate that app need 750-1500 VIs. 
     dbaechtel wrote:
    The LabView Clean Up Diagram function often works poorly.... 
    THe clean-up works fine for how I use it. After throwing together "scratch code" and debugging the "rats nest" I'll hit clean-up as a first step. It guess good enough on simple digrams and in some cases inspires me to structure the diagram in a different way that I may not have thought about. If I don't like, ctrl-z.
    Good deisgn and modualr implementaion led to smaller diagrams that just don't need thrre screens.
     dbaechtel wrote:
    My troubleshooting strategies don't work well for large diagrams and complex applications....Can anyone offer their advice on how best to use the LabView features to achieve these results in complex applications? I hope that you can help show me the light.
    Smaller diagrams single step faster since the sub-VI run full speed. I cringe thinking about a 3-screen diagram with multiple probes open ( shivver!).
    Re: Nestested structres
    Sub-VIs (wink, wink, nudge, nudge)
    If it works you have prven the concept is possible. That is the first step in an application.
    I hope that gives you some ideas.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to use labview to create a Menu?

    Hi I would like to use labview 8.0 to create a Menu interface, anyone can tell me how to do it?
    Thanks,
    Mike

    Click on the Edit>>Run time menu button, and this will open up a menu editor for you.
    In your code, you can use an event structure with the "Menu Selection User Event" to handle the menu selection.
    Open up the Example Finder in LabVIEW and search for Menu.  There are 6 or 7 examples there that will get you started.
    S G
    Certified LabVIEW Architect, Certified TestStand Developer, Certified Professional Instructor

  • How to use Labview to input some DOS command

    Dear everyone,
    This is the first time I program external device using Labview. You may come up the solution for me in 2 seconds, but it took me more than 20 hrs and still not success.
    My question is I need to control a 68HC11 device. It seems like I need to use DOS to upload a *.S19 file before I am able to talk with the device. Is there any way, I can upload the S19 file and some setting using Labview instead to go to DOS? I try to use DOS to upload S19 file and do setting FIRST and then use Labview to input command, but it doesn't success.
    Please help!!
    Thanks
    Attachments:
    PROGRAM.txt ‏2 KB
    BM_11.DOC ‏20 KB

    It seems you are using zterm from the commandline to communicate to a serial device (this is not DOS per se, you are just using a DOS window to start the zterm program).
    You should be able to duplicate all that in LabVIEW by communicating directly with the serial port. Are you sure you have to program your module every time?
    Apparently, F9 initiates some file transfer. Do you know what standard it uses (e.g. xmodem, zmodem, etc.)? LabVIEW does not incoroprate serial transfer utilities, but there might be utilities available elsewhere (see this note).
    There should also be no problem uploading the code using zterm, then later
    communicate with the device using LabVIEW by sending commands to the serial port. What do you mean exactly by "but it doesn't success". How are you communicating? What kind of errors are you getting?
    LabVIEW Champion . Do more with less code and in less time .

Maybe you are looking for