Jump to content

iPod service?


Recommended Posts

Ok, someone was trying to help me use iPodservice.exe, and explained it in Basic... Can anyone help translate this into autoit?

I've got more in the book, but it'd be long to type.

I'll do an example though, and include all pertinent information:

iPod and iTunes Hacks wrote:

1) Go to file->new->project

2) Under VB Projects, select Console Application

...

The first thing that you want to do is add a reference to ipodservice.exe, because this contains the API functions:

1)In the solution explorer window, right click references and click add reference.

2) Choose the COM tab

3) Scroll down until you see iPod Service Type Library in the list, or browse to the location of the file. Select it, and hit the ok button.

...

When you're writing any code to access the ipod, the first thing you need to do is declare and instantiate a reference to IPODSERVICELib.iPodManagerClass. This contains a lot of the API calls you'll use when developing for the iPod. In the code window, under the line that reads Sub Main(), type the following line:

Dim iPodManager As New IPODSERVICELib.iPodManagerClass()

You have now declared iPodManager to be a reference to iPodManagerClass().

...

In this example, all we're going to do is get the name of the iPod and pop up a window telling you the name. To do this, we need to declare an integer that will hold the numeric ID of your iPod and a string value to hold the name of your iPod:

Dim iPodID As Integer = 0

Dim DeviceName As String = ""

Before we can start doing anything with the iPod, we first need to log into it:

iPodManager.Login(1)

The number in the parentheses represents the ID of the application we want to log in as. In this case, we chose 1, because that is the ID of the iPod Updater; however, we could have chosen 4, which is the ID of iTunes. A complete list of the registered applications can be found in the windows registry under the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Apple Computer, Inc.\iPod\RegisteredApps

Now that we have logged in successfully, we can get the name of the iPod:

iPodID = iPodManager.FindFirstiPod(1)

DeviceName = iPodPrefs.DeviceName(1, iPodID)

This gets the ID of the first iPod found, then it stores the name in the string DeviceName.

Once we have the iPod's name, we can log out and display a message box with the name:

iPodManager.Logout(1)

MsgBox("Your iPods Name is:" & DeviceName)

It's as simple as that. The majority of the API calls work like the preceding example: first, you log into the iPod using the Login() function, and then you simply call the desired API function with the appropriate parameters. For example, the DeviceName() API call used in the previous example has as parameters the ID of the application used to log in and the ID of the iPod.

It's worth remembering that before you use any of the Updater API calls (They all begin with U_), you first need to call U_InitUpdater. Otherwise, the API calls will fail and return an error or a blank/null value.

Aha, you might like this source example:

Quote:

'Both the hardware version and the drive letter

'are returned as unsigned 32 bit integers, so the

'variables to store the values need to be declared

'as that type

Dim HWVersion As System.UInt32

Dim DriveLetter As System.UInt32

'Remember from the previous example

Dim iPodID As Integer

Dim iPodManager As New IPODSERVICELib.iPodManagerClass()

'Log into the iPod and retrieve the numeric ID of the iPod attached to

'the system

iPodManager.Login(1)

iPodID = iPodManager.FindFirstiPod(1)

'In order to get information about the hardware

'version and drive letter, the ipod needs to be locked

'to ensure that other applications can't access it

'To do this, call the LockiPod() method, passing it

'the ID of the iPod you want to lock

iPodManager.LockiPod(1, iPodID)

'To get information about the iPod's drive letter

'the iPod needs to be mounted and the HDD accessable

'To ensure this is the case, call the Mount()

'method, again passing the ID of the iPod you want to mount.

iPodManager.Mount(1, iPodID)

'The methods for getting the drive letter and the

'hardware version are part of the Updater API calls.

'As Discussed in the text, before these can be used,

'the U_InitUpdater() method MUST be called.

iPodManager.U_InitUpdater()

'To get the drive letter, call the

'U_GetDriveLetter() method, passing as a parameter

'the variable in which to store the drive letter.

iPodManager.U_GetDriveLetter(DriveLetter)

'As with getting the drive letter, to get the hardware

'version, call the U_iPodGetHWVersion() method,

'passing as a parameter the variable in which to store

'the hardware version.

iPodManager.U_iPodGetHWVersion(HWVersion)

'Display a pop-up message with the hardware revision

'In order to be displayed, it is converted to a string

'using the ToString() method built into the .net framework

MsgBox("iPod Hardware Revision" & HWVersion.ToString())

'Display another pop-up message, this time with the drive letter.

'As the drive letter is returned as a number,

'it also needs to be converted to a letter.

'First, the returned value is converted to a 16-bit

'integer. This value is used with the Chr() function,

'which converts a number to its

'ASCII equivalent (A-Z is 65-90).

'Once the conversion has been done, the letter is

'displayed in the pop-up message.

MsgBox("iPod Drive Letter:" & Chr(System.Convert.ToInt16(DriveLetter)))

'All the operations have been performed on the iPod,

'so it needs to be unlocked, unmounted, and logged out,

'ready for use by other applications

iPodManager.UnlockiPod(1, iPodID)

iPodManager.Unmount(1, iPodID)

iPodManager.Logout(1)

Although more complicated than the first example, the basic idea stays the same. All you need to do is call the desired function with the correct parameters and then read the result.

Link to comment
Share on other sites

Not 100% sure but I believe it's along these lines:

iPodManager = objCreate("IPODSERVICELib")

  ;then you can use the functions found in your explanation
  ;IE:

  iPodManager.Login(1)
  iPodID = iPodManager.FindFirstiPod(1)

This is not tested and I'm not 100% sure that "IPODSERVICELib" is the correct name of the object, keep us posted. :P

Edited by ame1011
[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]
Link to comment
Share on other sites

Nope, it's not working... first I tried this:

$iPodManager = objCreate("IPODSERVICELib")

$iPodManager.Login(1)
$iPodID = $iPodManager.FindFirstiPod(1)

Then this

$iPodManager = objCreate("IPODSERVICELib.iPodManagerClass")

$iPodManager.Login(1)
$iPodID = $iPodManager.FindFirstiPod(1)

And both times recieved this message:

C:\Documents and Settings\Owner\Desktop\New AutoIt v3 Script.au3 (3) : ==> Variable must be of type "Object".:

$iPodManager.Login(1)

$iPodManager^ ERROR

Any ideas?

Edited by magician13134
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...