carbon

Getting the process id of a Carbon C++ application

Is there a way of getting the process id of my C++ application? I am using the Carbon framework, but not Cocoa ...

Crafting .webloc file

I'm writing a program (for Mac OS X, using Objective-C) and I need to create a bunch of .webloc files programmatically. The .webloc file is simply file which is created after you drag-n-drop an URL from Safari's location bar to some folder. Generally speaking, I need an approach to create items in a filesystem which point to some locat...

Carbon vs Cocoa, is Carbon a dead end with OS X?

What are the trade-offs for using Carbon vs. Cocoa considering a developer with about 15 years of programming experience already in C/C++. Is Carbon a dead end with OS X? ...

How can I determine the running Mac OS X version programmatically?

Hi everybody, I have a program which needs to behave slightly differently on Tiger than on Leopard. Does anybody know of a system call which will allow me to accurately determine which version of Mac OS X I am running. I have found a number of macro definitions to determine the OS of the build machine, but nothing really good to determi...

Finding DNS server settings programmatically on Mac OS X

I have some cross platform DNS client code that I use for doing end to end SMTP and on windows I can find the current DNS server ip addresses by looking in the registry. On the Mac I can probably use the SystemConfiguration framework as mentioned in the first answer, however the exact method of doing so is not immediately obvious. For i...

Resolving AliasRecord with relative path on a new volume

I have an AliasRecord creating using the Alias Manager function FSNewAlias(fromFSRef, targetFSRef, &aliasRecordHandle). My understanding is that the resulting alias record will contain information for a relative path search (relative to fromFSRef). Because my users are on networked home directories and mobile accounts, these aliases do n...

How to unmount WebDAV volumes using Carbon without a lengthy blocking period?

I'm trying to unmount a WebDAV volume (mounted with FSMountServerVolumeSync()) using either FSUnmountVolumeSync() or FSEjectVolumeSync(). Thus far I've been unable to get either of them to reliably unmount the volume without blocking for more than 20 seconds. While they're blocking I can see webdavfs_agent complaining in Console.app th...

Editing resource forks on the command line on Mac OS X

Mac OS X stores some files with resource forks. I need to create a file with a resource fork. The trouble is, I need to create this file on the command line. Is anyone aware of how you can create a file with a resource form on the command line in Mac OS X? ...

Getting a unique ID for a window of another application

Hello all. I'm a newbie Cocoa developer and I'm developing my first application. I want to read a unique identifier from any window of any application - whether it's Cocoa or Carbon. Cocoa applications make their window IDs available to AppleScript (although I'm sure there's a much better way to do this through a proper Objective C route...

Suggestions other than an AppleScript OSAX to create a resource bound file

I need a create a specific type of file in OS X. It needs resources in a specific way. Currently, the only way I can find to do this is in AppleScript with an OSAX. This is slow, about 1 second round trip to run, since the OSAX must open, load, do it's job, and quit. I have explored doing it in C, but that would be a last resort, as ...

OS X equivalent to OutputDebugString() ?

I'm examining the feasibility of porting an existing Windows MFC control to OS X/Carbon. My test bed is a C++ Carbon application generated using the XCode 3 Wizard. I'm looking for a quick way to dump some trace info to the debugger or the OS X equivalent of DbgView. On Win32 I'd use OutputDebugString() - what's the deal on OS X? Is th...

Macintosh C Creating a navigation window to choose an app

I'm writing a C program for mac, and I need to allow the user to choose an application to send an apple event to. I can create a navigation window, using NavCreateChooseFileDialog, but I can't get it to enable any .app files. If I restrict the types using NavDialogSetFilterTypeIdentifiers, it will only allow me to select applications lik...

Is there a way to programmatically hide an carbon application on osx?

I have a carbon C++ application and I would like to programmatically do the equivalent of Command-H (to hide the application) which is available in the Application menu for my app. I have explored the carbon API for TransitionWindow and HideWindow and while these can hide my window, they do not do the equivalent of Command-H. I looked in...

Putting a CGImageRef on the clipboard

I'm trying to copy a CGImageRef to the clipboard pasteboard. I found a function that claims it should do this by creating a destination from (zero sized), adding the image to the destination, finalizing, then PasteboardPutItemFlavor the ref into the clipboard. However it doesn't work, so two questions: Is this the correct way to go ab...

How can I tell if Voice Over is turned on in System Preferences?

Is there an way, ideally backwards compatible to Mac OS X 10.3, to tell if "Voice Over" is activated in System Preferences? ...

Event taps: Varying results with CGEventPost, kCGSessionEventTap, kCGAnnotatedSessionEventTap, CGEventTapPostEvent

I'm running into a thorny problem with posting an event from an event tap. I'm tapping for NSSystemDefined at kCGHIDEventTap, then replacing the event with a new one. The problem I'm running in to is that depending on how I post the event, it's being seen only by some applications. My test applications are Opera, Firefox, Quicksilver, an...

Fonts for Carbon OpenGL app on OS X

Hi, I'm trying to add text rendering to a Carbon OpenGL app I'm developing for OS X. Since the aglUseFont is now deprecated, I'm looking for another way to add text as well as be able to query the glyph properties (i.e. width, height, spacing, etc) So far I've investigated CoreText and ATSUI but both without much luck. Please help me...

How to set text in Carbon textfield on OSX?

I'm trying to set the text of a textfield using the Carbon API like this: ControlID editId = {'EDIT', 3}; ControlRef ctrl; GetControlByID(GetWindowRef(), &editId, &ctrl); CFStringRef title = CFSTR("Test"); OSErr er = SetControlData(ctrl, kControlEntireControl, kControlEditTextTextTag, CFStringGetLength(title), title); CFRelease(title...

Exception wrapper for Carbon C app in OSX

How can I efficiently catch and handle segmentation faults from C in an OSX Carbon application? Background: I am making an OSX Carbon application. I must call a library function from a third party. Because of threading issues, the function can occasionally crash, usually because it's updating itself from one thread, and it's got some in...

How to detect whether an OS X application is already launched

Normally an application bundle on OS X can only be started once, however by simply copying the bundle the same application can be launched twice. What's the best strategy to detect and stop this possibility? On Windows this effect can simply be achieved by the application creating a named resource at launch and then exit if the named r...