Re: Extending the Registry donated-code #2
"Christophe Bouhier (MC/ECM)" <[email protected]> Fri, 1 Jul 2005 09:33:48 +0800
| Newsgroups | gmane.comp.windows.devel.jawin |
|---|---|
| Message-ID | <54F404A6467B0242BBBE0E5EB405C295D8030B@emyklmw104> |
Hi Morten, No problem, I will add javadoc comments and also extend RegistryConstants so various value types can be written (REG_SZ etc...) I will try to make this a more generic method. Also I can't get the enum calls to work, so I'll try to fix them. Cheers / Christophe > -----Original Message----- > From: Discussion of Java/Win32/COM integration with Jawin > [mailto:[email protected]]On Behalf Of Morten Andersen > Sent: vrijdag 1 juli 2005 3:47 > To: [email protected] > Subject: Re: [JAWIN] Extending the Registry donated-code #2 > > > Hi Christophe, > > I placed a few comments below, but first thanks for taking the time to > delve into the source. The FuncPtr marshalling string for > DLL-entry-point invocations is unfortunately still > work/documentation in > progress :-). > > Christophe Bouhier (MC/ECM) wrote: > > Hello again, > > > > I figured out the short-cut methods won't do the job. I > have to call the generic > > invoke method. The serialization is very challenging, I > managed to do what I want, > > without being to sure of what I am doing :) I would > appreciate if someone can check if the > > instruction string is correct and how to process a return value?? > > > > here is the code. > > > > fpSKV = new FuncPtr("ADVAPI32.DLL", "RegSetValueExW"); > > > > public static void SetKeyValue(int key, String name, String > value) throws IOException, COMException { > > > > NakedByteStream nbs = new NakedByteStream(); > > // wrap it in a LittleEndianOutputStream > > LittleEndianOutputStream leos = new > LittleEndianOutputStream(nbs); > > // and then write the Java arguments > > leos.writeInt(key); // 4 bytes. > > leos.writeStringUnicode(name); // 4 bytes, this is PTR > > leos.writeInt(0); // 4 bytes > > leos.writeInt(1); // type like REG_NONE = 0, REG_SZ > =1, REG_EXPAND_SZ=2 etc.. > > leos.writeStringUnicode(value); > > leos.writeInt((value.length()*2)); > > // System.out.print("Stream length=" + nbs.size() ); > > fpSKV.invoke("IGIIGI:T1:", 24, nbs, null, > ReturnFlags.CHECK_NONE); > > > > // T1 throws exception with The operation completed > successfully. > > // T7 is no exception > > I assume that the Tx-out-instruction strings are obsolete by know > (unfortunately I think the *exact knowledge* of this is lost in the > Jawin history, when Stuart left the project). So I would > suggest instead > an instruction string like: > "IGIIGI::" > and a returnflags value: > ReturnFlags.CHECK_W32 > > Please try that with a couple of calls that should > 1) Succeed, and verify that it actually succeds. > 2) Fail (eg. by writing to key protected by ACL, or > to a non-existing > key), and verify that it actually throws an exception. > > Unfortunately I am not sitting at a Windows platform pt., so > I am unable > to test this for myself. > > > } > > > > > > Can I get CVS access to commit the Registry stub? > > I can commit it for you, as soon as you declare it ready for > commit'ing. > It would be great if you would add a couple of lines javadoc for the > method, eg. with a link to the MSDN API description: > http://msdn.microsoft.com/library/default.asp?url=/library/en- us/sysinfo/base/regsetvalueex.asp and a short note on the implementation ONLY supporting writing of REG_SZ values. If you choose to supply a diff-file, feel free to mail it to me off-list, as I don't think the maillist forwards any attachments. Best Regards Morten