June 3, 2007 : Software Development at Home
© 安岡喜晴 (JoyShine)
Today I worked on software development at home~. I have to get the software I was asked to make finished by tomorrow.
And....., before that....., I started on the two things I'd been getting requests about for a long time:
more words in the medical dictionary for the Japanese IME, and a faster install.....
To speed up the install, I tried to call the API directly from the system.....,
but for some reason, getting the styles the IME supports just won't work.....
Structure STYLEBUF
Dim dwStyle As Integer
Dim szDescription As String
End Structure
I declared the STYLEBUF structure,
Private Declare Function GetKeyboardLayout Lib "user32.dll" (ByVal dwLayout As Integer) As Integer
Private Declare Function ImmGetRegisterWordStyle Lib "imm32.dll" Alias "ImmGetRegisterWordStyleA" (ByVal hKL As Integer, ByVal nItem As Integer, ByVal lpStyleBuf As STYLEBUF) As Integer
Private Declare Function ImmRegisterWord Lib "imm32.dll" Alias "ImmRegisterWordA" (ByVal hKL As Integer, ByVal lpszReading As String, ByVal dwStyle As Integer, ByVal lpszRegister As String) As Integer
Private Declare Function ImmUnregisterWord Lib "imm32.dll" Alias "ImmUnregisterWordA" (ByVal hKL As Integer, ByVal lpszReading As String, ByVal dwStyle As Integer, ByVal lpszUnregister As String) As Integer
declared the four API functions above,
Dim hk As Integer
Dim X_STYLEBUF(0) As STYLEBUF
Dim StyleCount As Integer
hk = GetKeyboardLayout(0) //Get the input locale identifier for the active thread
StyleCount = ImmGetRegisterWordStyle(hk, 0, X_STYLEBUF(0)) //Get the number of styles supported by the IME currently in use
ReDim X_STYLEBUF(StyleCount - 1) //Change the number of elements in the array
rc = ImmGetRegisterWordStyle(hk, StyleCount, X_STYLEBUF(0)) //Copy the styles into X_STYLEBUF
and once I had it set up as above, for some reason I get an object reference error.
Why is that.....? Maybe there's something wrong with the third argument I pass to ImmGetRegisterWordStyle.....
In the spec, the third argument of ImmGetRegisterWordStyle is supposed to be an address, though.....
But....., even if I pass the first element of the array, I feel like what I'm passing is the address of the start of the array anyway.....
Maybe the problem is in how I declared the STYLEBUF structure~? That's what I thought,
so I declared szDescription as a byte array, but that didn't work either.....
I wondered if the API itself was broken..... so I looked into imm32.dll from all sorts of angles.....,
but I still can't quite figure out the cause.....
Then again, it seems imm32.dll has quite a few errors depending on the version of the IME the user has, and it doesn't fully support every version.
Which means..... in the end, I wonder if Microsoft just cut corners on the development.....
Well, it doesn't really matter....., because on some other free day when I have the time, I'll try rewriting it again, in C++ this time.
So anyway....., I decided to turn the engine part above into a DLL in C++ on another day and call it from there.....
Feels like that ate up a ridiculous amount of time..... I have to hurry and finish the work that's due tomorrow.....
Come to think of it....., I also have to put together the presentation materials for the diabetes department by June 7.....
Things have been easy since I moved here from the University of Tokyo Hospital.....,
but I have a feeling I'm about to go into busy mode for a few days, for the first time in a while.....