drag&drop filename

  • I am trying to get the filename of provided file (as argv[1] -
    psn_0_... ) to my cocoa app, upon start.

    This is the code that I am using but without luck, after two days
    googling for a solution:

        ProcessSerialNumber psn =
    { StripPsnStrAndGetHighLong( argv[ 1 ] ), 0 };
        ProcessInfoRec info;
        FSSpec fs;

        info.processAppSpec = &fs;

        GetProcessInformation( &psn, &info );

        I expected to have the filename here info.processAppSpec->name but
    there is garbish :-(

    Any hints ? thx!

    Paul
  • On Dec 2, 2007, at 5:42 AM, Paul Grant wrote:

    > I am trying to get the filename of provided file (as argv[1] -
    > psn_0_... ) to my cocoa app, upon start.

    You do realize that when you drop a file on an application's icon in
    the finder, it is not pass as one of the command line arguments,
    right?  So if you have an issue with supporting drag & drop, check out
    NSApplication's delegate open methods.

    > This is the code that I am using but without luck, after two days
    > googling for a solution:
    >
    > ProcessSerialNumber psn =
    > { StripPsnStrAndGetHighLong( argv[ 1 ] ), 0 };
    > ProcessInfoRec info;
    > FSSpec fs;
    >
    > info.processAppSpec = &fs;
    >
    > GetProcessInformation( &psn, &info );
    >
    > I expected to have the filename here info.processAppSpec->name but
    > there is garbish :-(

    At best, this will get you a pascal style string (which can't
    accurately represent all file names in a manner that is useful).
    FSSpec's are very depricated and shouldn't be used for new code...

    If you want the process name, check out NSProcessInfo.

    Glenn Andreas                      <gandreas...>
      <http://www.gandreas.com/> wicked fun!
    quadrium | prime : build, mutate, evolve, animate : the next
    generation of fractal art
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today