how to access notifications

Joined
Dec 28, 2009
Messages
5
Reaction score
0
Points
1
Hi all,

i am developing an application , my application is to show when i plug my usb device it has to give a message that new hardware found and when i unplug it , it has to show device is removed,
can any one give examples applications
my code is:


result = IOMasterPort(MACH_PORT_NULL, &masterPort);
printf("iomasterport %d\n",result);
if(result != KERN_SUCCESS)
{
printf("IOMasterPort Error\n");
return 0;
}
classToMatch = IOServiceMatching("moschipNHCI");

printf("Classtomatch %d\n",classToMatch);
if(classToMatch == NULL)
{
printf("IOServiceMatching() Error\n");
return 0;
}
result = IOServiceGetMatchingServices(masterPort,classToMatch,&iterator);
printf("ioserviceresult %d\n",result);
if(result != KERN_SUCCESS)
{
printf("IOServiceGetMatchingServices() Error\n");
return 0;
}
else
{
NSRunAlertPanel(@"Alert",@"find new hardware1",@"ok",@"",nil);
printf("IOServiceGetMatchingServices success1234\n");
}
serviceObject = IOIteratorNext(iterator);
IOObjectRelease(iterator);
if(serviceObject)
{
result = IOServiceOpen(serviceObject ,mach_task_self() ,0 ,&dataPort );
if(!serviceObject)
{
printf("IOServiceGetMatchingServices() Error\n");
return 0;
}
else
{
printf("IOServiceOpen Succes\n");
// sleep(5);
}
}
IOObjectRelease(serviceObject);
result = IOConnectMethodScalarIScalarO(dataPort, kMyUserClientOpen, 0, 0);
printf("ioconnectresult %d\n",result);
if(result != KERN_SUCCESS)
{
printf("kMyUserClientOpen Error\n");
IOServiceClose(dataPort);
return 0;
}
else
{
printf("kMyUserClientOpen Success\n");
}
// int resultNumber;
// result = IOConnectMethodScalarIScalarO(dataPort, kMyScalarIScalarOmethod, 2, 1, 5, 40, &resultNumber);
// printf("result = %d\n", resultNumber);

// result = IOConnectMethodStructureIStructureO(dataPort,kMyStructIStructOmethod,reqStructSize,&retStructSize,&reqStruct,&retStruct);
// printf("int1 ->%d int2->%d string ->%s\n", retStruct.int16, (int)retStruct.int32, retStruct.string);

return TRUE;




Regards,
kiran
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top