Results 1 to 6 of 6

Thread: Launching an application

  1. #1
    Dimension
    Guest

    Launching an application

    I need to lauch abode acrobat and pass it a file name i would like it to open and then print. Does anyone know how to do this? Help is appreciated! Thanks!

  2. #2
    jim mcnamara
    Guest
    Try ShellExecute:

    Code:
    HINSTANCE H;
    
    H = ShellExecute(
        this,
        (LPCTSTR) "print",
        (LPCTSTR) "c:\foldername\program_name",
        (LPCTSTR) "c:\anotherfolder\anotherfile.pdf",
        (LPCTSTR) "c:\",
        SW_NORMAL
    );

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You shouldn't need to cast it there, also, you're casting to an unsafe type, use:
    Code:
    HINSTANCE H;
    
    H = ShellExecute(
        this,
        _T("print"),
        _T("c:\\foldername\\program_name"),
        _T("c:\\anotherfolder\\anotherfile.pdf"),
        _T("c:\\"),
        SW_NORMAL
    );
    LPCTSTR is const TCHAR*, where TCHAR is either char or wchar_t depending on the definition of UNICODE.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    _T will evaluate to a wide string or an ANSI string dependent on UNICODE.

    Mind the double \! Since \ is the escape character, i.e. it has a special meaning, you need to escape it to get the real character: \\.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    jim mcnamara
    Guest
    I used LPCSTR since they were all constants. Which is alright in this instance.

    I did not escape the \ to \\, which is not alright.

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Originally posted by jim mcnamara
    I used LPCSTR since they were all constants. Which is alright in this instance.
    Mm-hmm, but they don't match the datatype (TCHAR).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width