CMI interface

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

It would be very, very, very helpful if someone from MS could post the CMI
interface.

I'm trying to get a default theme loaded, which seems to be impossible.
So I thought I'd just write all the colors, sizes and so on to the target
registry after TD build. Well the strings I figured out, but the binary
values are a problem.

Examples:

oPL.TargetRegEdit cRegOpWrite, cRegCondAlways, cmiREG_EXPAND_SZ, sKey,
"TileWallpaper", "1", cmiString (works)


oPL.TargetRegEdit cRegOpWrite, cRegCondAlways, cmiREG_BINARY, sKey,
"UserPreferencesMask", 9e3e0480, cmiBinary (doesn't work)

And this would all be a lot easier if the CMI interface was properly
documented.

Hope someone knows it all.

Thijs





value
 
In your example, there is nothing CMI related that gives you the problem. It is rather wrong VB script syntax.
You should analyze the VBS errors you are getting from running that script.

I think it fails for you because you are sending the wrong argument value for the binary type.
Here is how you may want to fix it:
Dim aVal : aVal = Array(158,62,4,8) ' In hex: 9e3e0480
oPL.TargetRegEdit cRegOpWrite, cRegCondAlways, cmiREG_BINARY, sKey,
"UserPreferencesMask", aVal, cmiBinary (doesn't work)

Also, you are asking not only about opening CMI interface but rather TD script as well since you are using TD script objects like
Platform (oPL).
But I totally agree, CMI docs should be open to public at least for information purposes (without support from MS). There is nothing
really hidden or secret in CMI interfaces since it's been already hacked.
 
KM, you're completely right, the argument is the problem.
I need to add some registry export values, binary of course, without editing
the original data to much. So after some some trial and error i came up with
this:

original registry export data:
=============================================================================================
[HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics
"CaptionFont"=hex:f5,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,bc,02,00,00,\
00,00,00,01,00,00,00,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,\
00,20,00,53,00,61,00,6e,00,73,00,20,00,53,00,65,00,72,00,69,00,66,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0
=============================================================================================

code to merge it
=============================================================================================
Sub cmiOnEndBuild(dwFlags)
Dim sKey, oVar

sKey = "HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics"

oPL.TargetRegWrite cmiREG_BINARY, sKey, "CaptionFont", _
Str2Arr("f5,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,bc,02,00,00,"
& _

"00,00,00,01,00,00,00,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,"
& _

"00,20,00,53,00,61,00,6e,00,73,00,20,00,53,00,65,00,72,00,69,00,66,00,00,00,"
& _
"00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00"),
cmiBinary
End Sub

Function Str2Arr(sHex)
Dim bArray(), nIdx, sLocal
sLocal = sHex
iIdx = 0
While (Len(sLocal) >= 2)
ReDim Preserve bArray(nIdx)
bArray(nIdx) = CByte("&h" + Left(sLocal, 2))
sLocal = Mid(sLocal, 4)
nIdx = nIdx + 1
Wend
Str2Arr = bArray
End Functio
=============================================================================================


BTW is there a wiki/post/forum in which we could store the collective
knowledge of the the CMI interface.


Thijs
 
I see.

You could also do that by using this function, for example:
Function StringToMultiByte(S)
Dim i, MultiByte
For i=1 To Len(S)
MultiByte = MultiByte & ChrB(Asc(Mid(S,i,1)))
Next
StringToMultiByte = MultiByte
End Function
 
If I feed this "f5,ff,ff,ff,00,00,00,00,00,00,00,00,00,00,00,00,bc,02,00,00"
to the function StringToMultiByte the result is
"?????????????????????????????"

As far as I understand this function creates a string and not a byte array,
see below, did I get it wrong?

Mid(S,i,1) => picks of one char at a time

Asc(...) => converts the char to it's ASCII-code

ChrB(...) => makes the ASCI-code 8 bits wide

MultiByte & ... => appends the char to the string

Thijs
 
My bad. Copied and pasted wrong piece of code where the outut was targeted to a binary file (this is why the result is yet string
from the sample code below).

Basically you'd want to create an array instead but the conversion logi could be the same.
Thinking twice about it I relaized you don't really have to mess with the code I posted since you code worked fine :-)
 
Back
Top