Loading ...
Sorry, an error occurred while loading the content.

File Association - Can't Find Double-Clicked File

Expand Messages
  • gregsweitzer
    I m trying to get my program to run and open a data file when the user double-clicks on an icon. I m using Windows XP. My installation creates the following
    Message 1 of 3 , Dec 2, 2007
    • 0 Attachment
      I'm trying to get my program to run and open a data file when the user
      double-clicks on an icon. I'm using Windows XP. My installation
      creates the following association:

      HKEY_CLASSES_ROOT:
      KBNAReporterFile
      shell
      open
      command

      The value of "command" is:
      "C:\Program Files\KBNA Reporter\kbna reporter.exe" "C:\Program
      Files\KBNA Reporter\kbna reporter.tkn" "%1"

      This works fine, but only when the data file is located in the
      application directory (..\KBNA Reporter). When the data file is
      located elsewhere, I get the Warning:

      "Runtime error: OS error: The system cannot find the file specified.
      See error.log for more information." (The error.log is below)

      Any suggestions? Thanks in advance for any help-

      Greg Sweitzer


      ==================
      Error log timestamp Sunday 12/02/07 03:47:27 PM

      Runtime error: OS Error: The system cannot find the file specified.

      Error(Exception)>>defaultAction
      Error(Exception)>>activateHandler: <anUndefinedObject>
      Error(Exception)>>handle
      Error(Exception)>>signal
      Error class(Exception class)>>signal: <'OS Error: The system...'>
      BasicRunProgram(Object)>>error: <'OS Error: The system...'>
      BasicRunProgram(BasicProgram)>>terminateRun: <aFileError>
      [] in BasicProgram>>errorHandlerBlock
      ExceptionHandler>>evaluateResponseBlock: <aBlockClosure> for:
      <aFileError>
      [] in ExceptionHandler>>handle:
      ProtectedFrameMarker(BlockClosure)>>setUnwind: <aBlockClosure>
      BlockClosure>>invisibleEnsure: <aBlockClosure>
      ExceptionHandler>>handle: <aFileError>
      ExceptionHandler>>findHandler: <aFileError>
      FileError(Exception)>>activateHandler: <anExceptionHandler>
      FileError(Exception)>>handle
      FileError(Exception)>>signal
      FileError class>>signal: <'OS Error: The system...'> hostErrorCode: <2>
      HostFileSystemError>>defaultAction
      ExceptionHandler>>findHandler: <aHostFileSystemError>
      HostFileSystemError(Exception)>>activateHandler: <anExceptionHandler>
      HostFileSystemError(Exception)>>handle
      HostFileSystemError(Exception)>>signal
      HostFileSystemError class>>signalWith: <2>
      FileHandle class>>osError: <2>
      FileHandle class(Object)>>osError
      [] in FileHandle class>>open:access:share:create:attributes:
      ExceptionHandler>>evaluateProtectedBlock: <aBlockClosure>
      [] in ExceptionHandler>>activateDuring:
      ProtectedFrameMarker(BlockClosure)>>setUnwind: <aBlockClosure>
      BlockClosure>>invisibleEnsure: <aBlockClosure>
      ExceptionHandler>>activateDuring: <aBlockClosure>
      ExceptionHandler class>>handle: <anExceptionSet> with: <aBlockClosure>
      during: <aBlockClosure>
      BlockClosure>>on: <anExceptionSet> do: <aBlockClosure>
      FileHandle class>>open: <'C:\Program Files\KBN...'> access:
      <2147483648> share: <3> create: <3> attributes: <128>
      FileHandle class>>open: <'Phineas Gage.kbn'> in: <aDirectory> access:
      <2147483648> share: <3> create: <3> attributes: <128>
      FileHandle class>>openReadOnly: <'Phineas Gage.kbn'> in: <aDirectory>
      File>>openReadOnly
      File>>readStream
      File class>>pathNameReadOnly: <'Phineas Gage.kbn'> in: <aDirectory>
      Directory>>fileReadOnly: <'Phineas Gage.kbn'>
      BasicFile>>from: <'Phineas Gage.kbn'> mode: <'INPUT'> handle: <'#n'>
      BasicFile class>>from: <'Phineas Gage.kbn'> mode: <'INPUT'> handle:
      <'#n'> owner: <aBasicRunProgram> length: <anUndefinedObject>
      [] in OpenCommand>>using:
      [] in BasicRunProgram>>begin
      ExceptionHandler>>evaluateProtectedBlock: <aBlockClosure>
      [] in ExceptionHandler>>activateDuring:
      ProtectedFrameMarker(BlockClosure)>>setUnwind: <aBlockClosure>
      BlockClosure>>invisibleEnsure: <aBlockClosure>
      ExceptionHandler>>activateDuring: <aBlockClosure>
    • rod_bird001
      It s because the runtime cant find the tkn because it expects to be in the same directory. If you involke the runtime by association the working directory
      Message 2 of 3 , Dec 2, 2007
      • 0 Attachment
        It's because the runtime cant find the tkn because it expects to be in
        the same directory. If you involke the runtime by association the
        working directory remains that of the data file. To get past it you
        need to force a CD somehow.

        This is not a workable solution but it has been discussed, I'm not
        aware of a fix lets hope someone has a solution.

        Have I got the problem right, you double click a .dat file anywhere on
        the system and expect your Liberty program to be involked and open
        the .dat file?

        http://libertybasic.conforums.com/index.cgi?
        board=novice&action=display&num=1189165845&start=45
      • gregsweitzer
        The file associations were O.K.; my LB code was funky. The code below allows the user to double-click on a data file anywhere on the disk, which starts the
        Message 3 of 3 , Dec 2, 2007
        • 0 Attachment
          The file associations were O.K.; my LB code was funky. The code below
          allows the user to double-click on a data file anywhere on the disk,
          which starts the program and loads that .dat file.

          if CommandLine$ <> "" then goto [FileOpenFrom2Click]
          [FileOpenFrom2Click]
          'Remove quotation marks from CommandLine$
          file$ = CommandLine$
          LET s=LEN(file$)
          IF s = 0 THEN END
          [StripLoop]
          num$ = CHR$(34)
          IF LEN(num$) = 0 THEN END
          n = INSTR(file$,num$)
          IF n=0 THEN GOTO [FileOpen]
          file$= LEFT$(file$,n-1) + RIGHT$(file$, s-n)
          LET s=LEN(file$)
          GOTO [StripLoop]
          [FileOpen]
          open file$ for input as #n
          gosub [ReadIt]
          close #n

          Thanks to Stefan for pointing out elsewhere on the web that
          <myapplication.exe> <myapplication.tkn> %1
          is generally the most successful for this type of task.

          Using Inno Setup for installation and registry modification, the
          registry settings are below. Lines beginning with >>> are remarks.

          [Registry]
          Root: HKCR; Subkey: ".KBN"; ValueType: string; ValueName: "";
          ValueData: "KBNAReporterFile"; Flags: uninsdeletevalue

          Root: HKCR; Subkey: "KBNAReporterFile"; ValueType: string; ValueName:
          ""; ValueData: "KBNA Reporter File"; Flags: uninsdeletekey

          Root: HKCR; Subkey: "KBNAReporterFile\DefaultIcon"; ValueType: string;
          ValueName: ""; ValueData: "{app}\KBNA.ico,0"

          Root: HKCR; Subkey: "KBNAReporterFile\shell\open\command"; ValueType:
          string; ValueName: ""; ValueData: """{app}\kbna reporter.exe""
          ""{app}\kbna reporter.tkn"" ""%1"""

          >>> see http://www.jrsoftware.org/isfaq.php#perms for formatting
          example of above line
          >>> "shell\open\command" is the registry key that specifies the program
          to execute when a file of the type is double-clicked in Explorer.
          >>> The surrounding quotes are in the command line so it handles long
          filenames correctly.
        Your message has been successfully submitted and would be delivered to recipients shortly.