Unable to edit IORegistryEntry

I am creating software on Mac and I would like to change the IORegistryEntry value. I can view it in the IORegistryExplorer, but I cannot edit it. So I understand that I need to edit it with code. Here is my code:

CFMutableDictionaryRef matchingDict = IOServiceNameMatching("AppleUSBMultitouchDriver");
io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
if(service) {
 CFStringRef manufacturer = IORegistryEntryCreateCFProperty(service, CFSTR("Manufacturer"), kCFAllocatorDefault,0);
 NSLog(@"%@", (NSString*)manufacturer);
 kern_return_t err = IORegistryEntrySetCFProperty(service, CFSTR("Manufacturer"), CFSTR("test"));
 NSLog(@"error = %d", err);
}

      

This will lead to the conclusion

2010-04-10 16:09:09.015 Test[41548:a0f] Apple Inc.
2010-04-10 16:09:09.015 Test[41548:a0f] error = 0

      

But after checking the value in IORegistryExplorer, it still doesn't change. Does anyone have any suggestions?

thanks

+2


source to share


3 answers


For this to be possible, usually the hardware-specific driver you are modifying must implement setProperties () (in IOKit), which makes the change for you.



It's unlikely that Apple will implement setProperty () in their AppleUSBMultitouchDriver in such a way that you can change the manufacturer's name. They want to clarify what kind of fruit they are.;)

+1


source


Use IOConnectSetCFProperties instead of IORegistryEntrySetCFProperty. Pass it the dictionary with the settings you want to set.



For example, to disable three fingers for navigation, call it with a dictionary containing {TrackpadThreeFingerSwipe = 0; }

0


source


This is an example of how to properly change the trackpad settings. Trackpad.prefpane does exactly that, but it also stores this setting somewhere by default (if you don't know where exactly, ask here).

PS getEVSHandle () can be found in MachineSettings.framework.

PPS Tested on 10.5 and 10.6 only.

NSInteger zero = 0, one = 1;

CFNumberRef _numberWith0 = CFNumberCreate(kCFAllocatorDefault, kCFNumberNSIntegerType, &zero);
CFNumberRef _numberWith1 = CFNumberCreate(kCFAllocatorDefault, kCFNumberNSIntegerType, &one);

CFMutableDictionaryRef propertyDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, NULL, NULL);

CFDictionarySetValue(propertyDict, @"TrackpadThreeFingerSwipe", flag ? _numberWith1 : _numberWith0);

io_connect_t connect = getEVSHandle();

if (!connect)
{
// error
}

kern_return_t status = IOConnectSetCFProperties(connect, propertyDict);

if (status != KERN_SUCCESS)
{
//error
}

CFRelease(propertyDict);

      

0


source







All Articles