Could someone tell me what the problem is with the following code?
Code: Select all
short type = OLE.VT_BYREF | OLE.VT_VARIANT;
int ptr = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof);
Variant spDoc = new Variant(ptr, type);
auto.invoke(
getDispatcherId("DoVerb"),
new Variant[] {
new Variant("Documents[#4095]"),
new Variant(".SP"),
new Variant(),
spDoc,
new Variant(0)
});
OleAutomation autoDoc = spDoc.getAutomation();
Variant pageCount = new Variant(ptr, type);
autoDoc.invoke(
getDispatcherId(autoDoc, "GetProperty"),
new Variant[] {
new Variant("Pages.Count"),
pageCount,
new Variant(0)
});
System.out.println("page count=" + pageCount.getInt());
Variant spPageChars = new Variant(ptr, type);
autoDoc.invoke(
getDispatcherId(autoDoc, "GetSubPoint"),
new Variant[] {
new Variant("Pages[1].Text.Chars"),
spPageChars
});
OleAutomation autoPageChars = spPageChars.getAutomation();
Variant pageCharsCnt = new Variant(ptr, type);
autoPageChars.invoke(
getDispatcherId(autoPageChars, "GetProperty"),
new Variant[] {
new Variant("Count"),
pageCharsCnt,
new Variant(0)
});
System.out.println("char count=" + pageCharsCnt.getInt());