Run Windows Fax And Picture Viewer using Shell Command

doddwelldoddwell Member Posts: 65
Hello

I have a number of scanned .TIff Images that I woudl like the user to be able to open inside MS Windows fax And Picture Viewer. I have tried the HYPERLINK function but this does not work for me....so I am trying to get the SHELL function to do the trick. I can get the Shell function to work iff I try and open a text file in Notepad but I cant get the Windows Fax and Picture Viewer to run. This is my code:

ExecName := 'RunDLL32.exe C:\Windows\System32\Shimgvw.dll';
param := 'C:\Test.tif';
ret1 := SHELL(ExecName, param);

I get the following error:
The file name "RunDLL32.exe C:\Windows\System32\Shimgvw.dll" contains and invalid character that may not be used.

Any ideas? Thankyou

Comments

  • mdPartnerNLmdPartnerNL Member Posts: 802
    Guess.. in the execname there is a parameter too.
  • doddwelldoddwell Member Posts: 65
    I tried splitting it as you impied like this:
    ExecName := 'RunDLL32.exe';
    param := C:\Windows\System32\Shimgvw.dll'
    param1 := 'C:\Test.tif';
    ret1 := SHELL(ExecName, param, param1);

    But I get the error message "The operating system cannot find the file rundll32.exe"

    I have also tried substituting the space for an ASCII Charecter but can't concatenate a String with a Char so had to do this:

    spaceAscii = 13;
    ExecName := 'RunDLL32.exe' + FORMAT(spaceAscii) + 'C:\Windows\System32\Shimgvw.dll'
    param1 := 'C:\Test.tif';
    ret1 := SHELL(ExecName, param, param1);

    I end up with the same error in my original post:
    The file name "RunDLL32.exe C:\Windows\System32\Shimgvw.dll" contains and invalid character that may not be used.

    Many Thanks.
  • mdPartnerNLmdPartnerNL Member Posts: 802
    What command do you run in a DOS box, or Run ?
  • doddwelldoddwell Member Posts: 65
    This is what I enter into Run: (and it works):

    rundll32.exe C:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscreen C:\Test.tif

    Note - my earlier code snippet was missing the ImageView parameter. Actual code used is;

    ExecName := 'rundll32.exe C:\WINDOWS\System32\shimgvw.dll';
    param1 := 'ImageView_Fullscreen';
    param2 := 'C:\Test.tif';
    ret1 := SHELL(ExecName, param1, param2);

    I don't think it likes the space in ExecName.

    Thanks.
  • MBergerMBerger Member Posts: 413
    From the helpfile on Shell : "The parameters cannot be passed as part of the Name parameter. The Name parameter must be filled in and it must not contain any parameters except for the executable." the executable here is RunDLL32.exe, and the DLL to run is a parameter it takes.

    So try :
    Execname : 'RunDLL32.exe'
    Param : 'C:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscreen'
    param1 : 'C:\Test.tif'
  • mdPartnerNLmdPartnerNL Member Posts: 802
    //GaWshShell, Automation, 'Windows Script Host Object Model'.WshShell

    IF ISCLEAR(GaWshShell) THEN BEGIN
    //MOD_NAV6.0
    IF ISCLEAR(GaWshShell) THEN CREATE(GaWshShell, TRUE, TRUE);
    //MOD_NAV5.0
    IF ISCLEAR(GaWshShell) THEN CREATE(GaWshShell, TRUE);
    END;

    LiValue := 1;
    LbValue := FALSE; //Wait until finished

    GaWshShell.Run('rundll32 C:\WINDOWS\System32\shimgvw.dll, ImageView_Fullscreen C:\capture.png', LiValue, LbValue);
  • yukonyukon Member Posts: 361
    Hi ,

    Please try with below sample code. Specially it not so much different with MBerger's sample. Or if you want to use "Windows Script Host Object Model", you can follow by mdPartnerNL's sample.
    {====Variable
    ExeName       Text 1024
    ExeParameter  Text 1024
    PictureName   Text 1024
    }
    ExeName       := 'C:\windows\system32\RunDLL32.exe'; //i set path of "RunDll32.exe".
    ExeParameter  := 'C:\Windows\System32\Shimgvw.dll,ImageView_Fullscreen';
    PictureName   := 'C:\avatar1_3.GIF';
    SHELL(ExeName,ExeParameter,PictureName);
    //SHELL('C:\windows\system32\RunDLL32.exe','C:\Windows\System32\Shimgvw.dll,ImageView_Fullscreen','C:\avatar1_3.GIF');
    

    Best Regards,
    Yukon
    Make Simple & Easy
Sign In or Register to comment.