Re: User friendly machine name (gestaltUserVisibleMachineName?) [SOLVED]
Re: User friendly machine name (gestaltUserVisibleMachineName?) [SOLVED]
- Subject: Re: User friendly machine name (gestaltUserVisibleMachineName?) [SOLVED]
- From: Rolf <email@hidden>
- Date: Mon, 02 Jun 2003 21:00:09 +0200
Hi all,
I have found the solution. Thanks for pointing me in the right direction. Here is a class method that returns the Machine Name:
+(NSString * )machineName {
SInt32 gestaltReturnValue;
// Fetch machine name as pointer to PStr255 (Pascal String: Byte0=length, Byte1..255=Characters)
if (!Gestalt(gestaltUserVisibleMachineName, &gestaltReturnValue)) {
return [NSString stringWithCString: (char *)gestaltReturnValue + 1];
} else {
return @"Unknown";
}
}
/Rolf
30.05.2003 22:24:15, skrev Steve Christensen <email@hidden>:
>
On Friday, May 30, 2003, at 12:43 PM, Eric Schlegel wrote:
>
>
> On Friday, May 30, 2003, at 12:16 PM, Rolf wrote:
>
>
>
>> I'm trying to write a method to determine the user friendly machine
>
>> name (For example "PowerBook G4") in a Cocoa app.
>
>
>
> Are you referring to the machine name that's set in the Sharing
>
> preference pane? If so, try CSCopyMachineName in CarbonCore/OSUtils.h.
>
>
>
>> As far as I know the Carbon Gestalt Manager has to be used, and the
>
>> gestaltUserVisibleMachineName looks like the correct selector. I
>
>> wrote the attached code but it doesn't work. Gestalt() succeeds and
>
>> it returns a seemingly correct value. However GetIndString makes
>
>> sMachineName into an empty string. Does anybody know why ?
>
>
>
> I believe that 'STR#' resource is only supported on Mac OS 9, not X.
>
>
If you use gestaltUserVisibleMachineName, though, Gestalt.h says that
>
the selector returns a StringPtr that points to the machine name.
>
>
steve
>
_______________________________________________
>
carbon-development mailing list | email@hidden
>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.