4 ms·
I do remember depending on the site pinvoke.net quite a bit in the past - but yeah this was always possible with C#. It was even what made J++ (Microsoft's Java
by kerng 6y ago
I do remember depending on the site pinvoke.net quite a bit in the past - but yeah this was always possible with C#. It was even what made J++ (Microsoft's Java, before it became C#) unique compared to Sun's version in the 90s, as it allowed this kind of tight Windows integration also if I recall correctly.
- sedatk 6y agoDidn’t JNI allow that kind of integration?
- DaiPlusPlus 6y agoI think it was because MS’ Java’s standard libraries included Java wrappers over Win32 already, so programming beginners in Java can make “real”-looking Windows desktop GUI applications without knowing any C or at least knowing how to read *.h files and translate them to Java.
- josefx 6y agoMicrosoft had RNI which was comparable to JNI and could be used to write native code. It also had J/Direct which could be used to bind existing native code to a Java method declared native with only a comment, the closest to that for standard Java that I know of is JNA and apparently that wasn't around until 2007?
- int_19h 6y agoJNI is a bit different - you have to write code in C or C++ that wraps native APIs you want to call, in a certain very specific way that then makes it possible to call it via methods declared as "native" in Java. P/Invoke does not require such a layer - you simply declare enums, structs, and functions from the native API directly in your C# code, and then you can call them. For those familiar with Python, the Java way is more like writing a Python extension module in C, and the C# way is more like using ctypes (but way faster). Java has some third party libraries that are basically P/Invoke equivalent; JNA is probably the most used one.
- sn_master 6y agoIt was also possible in VB6, planet-source-code was the best source for that..
- buckminster 6y agoYou could even call the win32 api from 16-bit VB3 by going through the wow thunking api. It worked well but the declarations were quite hairy.
- sn_master 6y agoyup, you could even have multi-threads, hide inside other processes and run from there and all the C++ fun stuff..