• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: drag&drop filename
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drag&drop filename


  • Subject: Re: drag&drop filename
  • From: glenn andreas <email@hidden>
  • Date: Sun, 2 Dec 2007 08:55:58 -0600


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 email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next generation of fractal art




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >drag&drop filename (From: Paul Grant <email@hidden>)

  • Prev by Date: Re:[idea] a wiki page per method in the cocoa docs
  • Next by Date: Textfield
  • Previous by thread: drag&drop filename
  • Next by thread: change rect of tooltip in table view
  • Index(es):
    • Date
    • Thread