|
Variant arguments & com function calls: msg#00003windows.devel.jawin
I would like to thank everyone for responding to my questions. I will comment on a couple of the responses at a time below. > >public static final int DISP_E_PARAMNOTFOUND = 0x80020004; > > >For now you can use this to create a variant for optional arguments >(code >below not tried by me...): > >Variant missing = new Variant(); >v.vt = VarType.VT_ERROR; >v.scode = 0x80020004; > I will try this code as soon as I get a chance tomorrow and will inform the list of the results. > >If that works for you, then we should probably add > >public class Variant { >... >public static final Variant MISSING = new Variant(); >static { > MISSING.vt = VarType.VT_ERROR; > MISSING.scode = COMException.DISP_E_PARAMNOTFOUND; >} > >So that you can use Variant.MISSING for optional VARIANT args. > I also wanted to suggest some improvements to the Variant class. In general, now when I have to use a Variant, first I have to create a new instance with "new", and then assign the appropriate value using the appropriate setter method. I was wondering, if in general, a few 'convenience' constructors could be added in which the constructor arguments would be assigned into the appropriate value of the Variant instance e.g. new Variant(int intValue) assigns the boolValue to the bool value in the class. Certainly, it wouldn't make any to creae a constructor for each possible field in invariant, but it would be nice if there is one for some. >It should generally not be necessary to generate instances of >org.jawin.Variant. Most (if not all) marshalling will be handled >correctly by the automatic marshalling and the dispatch coercion >mechanism. Eg. java.lang.Integer -> VT_UI4. I can certainly confirm that the automatic marshalling and dispatch coercion works well when working directly with DispatchPtr-s and such ( I use it mostly from Jython and it works exceptionally well) . However, when I generated the Java classes using the com browser ( I generated them with the release version, I am not sure if the cvs version would generate differently), the Java method calls are generated, with Variant arguments, so if I use the generated Java hierarchy ( I generated class hierarchies for Excel and Word . I noticed that there were a few Win32 structures & others in cvs - should generated code for MS Office to CVS ? In general, the generation worked pretty smoothly with the release version however, I had to fix a few methods and arguments that didn't compile. I understand that in the general case, the code generation should work flawlessly; however, for newcomers to the project it will certainly add value to have a generated and working interface to MS Office). > >We don't have that pt. You can try with "null", which get marshalled >into VT_NULL, but I assume we need to marshal into VT_EMPTY to get >this >to work? But at least it sounds like it is something we have to >support. Using null (that gets marshalled to VT_NULL) definitely doesn't work as a substitute for the optional argument ( I get some kind of com exception). > >Hope this helps you a little bit. And as a sidenote, as I don't know >exactly what you are trying to do with Excel, but have you checked >the >POI project http://jakarta.apache.org/poi/, for writing/reading >Excel >files?. I had looked at POI in the past, and it certainly does look convenient for Excel and Word. However, I am quite impressed with Jawin at this point and would like to use the opportunity as a springboard for learning more on invoking other (non-Com based) native win32 functionality from Java. I read over the extended how-tos and it is starting to make a lot more sense ( I was even thinking of going over a Win32 programming book that I have and implementing the examples in Java / Jawin). Regards, Alex Kotchnev Developer / Systems Analyst Diversified Information Technologies ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ CONFIDENTIALITY NOTICE: If you have received this e-mail in error, please immediately notify the sender by e-mail at the address shown. This e-mail transmission may contain confidential information. This information is intended only for the use of the individual(s) or entity to whom it is intended even if addressed incorrectly. Please delete it from your files if you are not the intended recipient. Thank you for your compliance. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Variant arguments & com function calls: 00003, Robert Hastings |
|---|---|
| Next by Date: | Re: Variant arguments & com function calls: 00003, Morten Andersen |
| Previous by Thread: | Re: Variant arguments & com function callsi: 00003, Morten Andersen |
| Next by Thread: | Re: Variant arguments & com function calls: 00003, Morten Andersen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |