DLL functions and input descriptions? - vba

I am currently using vba and have found a couple of handy pieces of code on the internet.
However some of these pieces of code use functions from DLL's e.g(user32).
The code works fine but it frustrates me that I have no means of discovering such functionality myself except for stumbling upon code on the internet.
I basically want to know if there is a way of obtaining descriptions of what exactly a specific DLL function does and what the input parameters represent or can this only be done by looking at the DLL's in their original language?

Not in VBA as fas as I know, but pinvoke site can help a lot.
Chek how well explained is LogonUser for example. Easy to adapt VB.NET to VBA with all that info I think.

These functions are part of the native Win32 API.
They're all quite well documented on MSDN, Microsoft's SDK documentation for Windows programmers.
For example, you might see the GetParent function called, which returns a handle to the specified window's parent or owner. The documentation for that function is here.
Note how the documentation tells you what the function does, how it is prototyped in a C-style language, what each of its parameters are and what they mean, and what its return value is and what it means. Very comprehensive; guaranteed to answer almost all of your questions. You should definitely read the "Remarks" section for any function which you are unfamiliar. There are a lot of important caveats to the Win32 API—it's a very powerful, but very old C API. There are a lot of arbitrary limitations that the programmers were forced to work around, and now because of backwards compatibility, we've been saddled with those workarounds for generations. The very bottom also tells you what DLL file you need to specify in order to call that function. For example, GetParent is found in user32.dll.
In just about every case that I've tried (and I've gone searching for lots of docs), you can type the name of the function into Google and the appropriate MSDN page will be the first result.

Related

Atomineer Utils VB.NET XML Comment Documentation Not Working

I just downloaded the trial for this application and it doesn't seem to work. I went through the Quick Setup guide and it all looked great. Now when I place my cursor on a member of any type and press Ctrl+Shift+D it does nothing. I placed it on top, inside, etc... Nothing. If I press Ctrl+Shift+A (twice) on top of the member it tells me to place it "in the line of the form MyType myVariable;". I'm not quite sure what this means unless it's referring to C# but this project is VB.NET which it doesn't seem to recognize. Anyone else have this issue? I was hoping it would make things easier since I've read that it can document an entire document rather than having to member by member.
Using VS 2010 Premium.
Drop me an email to support (at) atomineerutils.com with a bit of example code that exhibits the problem, and I'll help you sort it out.
(edit)
Please note that AtomineerUtils only officially supports VB 9 onwards, although where the syntax of earlier versions is compatible (i.e. in most cases), it will still work perfectly well.
I've now investigated this, and I can't repeat the documentation behaviour you have mentioned - it works as expected for me. (However, I did find and fix a regression introduced to the Visual Basic handling in a recent version - a small coding glitch that meant some methods could be incorrectly documented as constructors, so thanks for indirectly helping me find this issue!)
All I can suggest is that if you see a problem in any application, the best (and often only) way to get it fixed is to let the author know!

Where can I find up-to-date documentation about the WCF Web API?

I've been strugling with WCF to do REST the way I want it to work. And apparently so has quite a few others. I've heard about the WCF Web Api project, but wrongly dismissed it without looking too closely at it. Sadly, now that I'm looking at it I find that the documentation is rather outdated. Like, this blog post has some nice information, but classes have changed, parameters have changed, in short, design has changed.
So I've been using an old example of how to plug in Json.NET (newtonsoft) as my serializier, only to realize that after I had it working, it wouldn't work for my IErrorHandler. Further I had a problem with how to Deserialize a string from the uri template to an operation Type parameter.
It appears however that I should be able to solve these two problems (and presumably many others that I haven't stumbled over yet) by using the media formatter extension point and what's referred to as Processor<..>s in outdated documentation, which is now HttpOperationHandler<..>s unless I've missunderstood.
My problem is rather basic, I can't figure out how to correctly configure my IIS-hosted app to use my operation handler, assuming I've implemented it correctly. Since it feels rather dumb to ask for instructions on such a basic thing, I'll rather ask where I can find some documentation on how to do this sort of thing? (Explanations are welcome of course.)
I'm not after seing which classes exist, or what their methods are named with what parameters. I can see all that in my object browser. I need documentation for the overall design, and/or examples implicitly describing things like:
How do the different classes in the API fit together?
How can I configure from web.config?
Must I rather do a custom HttpServiceHostFactory?
What and how are you meant to use the framework?
How should I extend to reach what sort of goals?
How should I configure to place the extensions in effect?
From the lack of answers I assume the documentation quite simply isn't ready.
I was looking for it on the codeplex site under the Documentation tab, and found outdated stuff.
However, after familiarizing myself a bit with Codeplex I found out that the good stuff was in this Discussion section. Searching a bit in there helped a lot to be honest.
Concerning config-file configuration, I didn't find anything, so I'm assuming this will be added as the last thing before official release. Meaning I'll use the HttpConfiguration in a custom HttpServiceHostFactory for now.
The trick about the HttpOperationHandlers was twofold: Firstly I was throwing an exception in my operation and hadn't implemented a global HttpErrorHandler yet. (Doh!) Secondly I didn't know that the parameter name of HttpOperationHandler<..>.OnHandle had to match the name of the operation parameter.

How to create a compiler in vb.net

Before answering this question, understand that I am not asking how to create my own programming language, I am asking how, using vb.net code, I can create a compiler for a language like vb.net itself. Essentially, the user inputs code, they get a .exe. By NO MEANS do I want to write my own language, as it seems other compiler related questions on here have asked. I also do not want to use the vb.net compiler itself, nor do I wish to duplicate the IDE.
The exact purpose of what I wish to do is rather hard to explain, but all I need is a nudge in the right direction for writing a compiler (from scratch if possible) which can simply take input and create a .exe. I have opened .exe files as plain text before (my own programs) to see if I could derive some meaning from what I assumed would be human readable text, yet I was obviously sorely disappointed to see the random ascii, though it is understandable why this is all I found.
I know that a .exe file is simply lines of code, being parsed by the computer it is on, but my question here really boils down to this: What code makes up a .exe? How could I go about making one in a plain text editor if I wanted to? (No, I do not want to do that, but if I understand the process my goals will be much easier to achieve.) What makes an executable file an executable file? Where does the logic of the code fit in?
This is intended to be a programming question as opposed to a computer question, which is why I did not post it on SuperUser. I know plenty of information about the System.IO namespace, so I know how to create a file and write to it, I simply do not know what exactly I would be placing inside this file to get it to work as an executable file.
I am sorry if this question is "confusing", "dumb", or "obvious", but I have not been able to find any information regarding the actual contents of an executable file anywhere.
One of my google searches
Something that looked promising
EDIT: The second link here, while it looked good, was an utter fail. I am not going to waste hours of my time hitting keys and recording the results. "Use the "Alt" and the 3-digit combinations to create symbols that do not appear on the keyboard but that you need in the program." (step 4) How the heck do I know what symbols I need???
Thank you very much for your help, and my apologies if this question is a nooby or "bad" one.
To sum this up simply: I want to create a program in vb.net that can compile code in a particular language to a single executable file. What methods exist that can allow me to do this, and if there are none, how can I go about writing my own from scratch?
What you're asking is a pretty complex question. Sure, at its core it seems pretty basic:
Interpret the code itself
Write out the interpreted code
but each of those steps can be pretty intense. Step 1 should be somewhat achievable with some time and a LOT of elbow grease - you need to parse the code into a number of control statements based upon the specification of the language. Check out http://en.wikipedia.org/wiki/Parsing for more information on this step. In essence you're converting the typed code into a common format that represents the functionality you want.
Once you've parsed the code, the next step would be to take that parsed code and convert it into machine-runnable code (typically assembly, though with VB.NET you can write Microsoft Intermediate Language code as the output and then run it in the CLR). This is what will actually create the executable file in a manner that lets the computer run the program.
Unfortunately, the best advice for solving this problem is to either:
Go purchase several books on a programming language, machine code, assembly language, compilers, and so on, then spend several months or years reading and experimenting until the knowledge you gain from the books results in your writing a successful compiler.
Enroll in a computer science program at a local university. Writing compilers and programming languages are usually covered at a rudimentary level during the second or third year of a BS in computer science, and then in much more depth at a graduate level.
Good luck!
EDIT: If all you're looking for is a way to write code and then write a way to execute it, you might try looking at writing an interpreter for one of the scripting languages that already exist - Ruby, Python, Lua, etc.
Process.Start(String.Format("vbc.exe {0}", sourceFilePath))
Here is one book that explains it all at a very basic level. Including sample code that you can get working in a matter of hours.
As with many programming endevors, it will take you many months of study to accomplish what you want. Good luck!!
Let me start by saying this is totally doable. Ignore the naysayers.
OK, so it seems you bit off more than you could chew here. I would suggest slightly re-evaluating your goal. It seems that you want to learn how compilers work, and writing a VB.net compiler is your project to get started.
Try instead to write an interpreter, which is a much smaller and simpler task. Here's how you do it:
Write a parser for a very very small language, maybe only supporting assignment statements. Use a parser toolkit, like Antlr. This will build an AST ("abstract syntax tree" - ie a few classes or objects representing the program's syntax, without the crap like semi-colons, as a tree), which will look something like this:
then you go through the AST, and just execute it. Google for "AST walker". So for the assignment x = 5, create a hashtable entry for 'x', assign 5 to it, then move on to the next statement.
keep adding features as you go.
Once you've got the full language, you'll probably have learned enough on the way to understand the compiler books. Don't use the dragon book, try Appel's book instead, or Cooper/Torczon. There are online books if you prefer, I've never tried them.
When you go to write the compiler, you'll just be changing the bit that executes the AST into one which generates assembly (or C if you prefer) which will do the same action when it's run.
I'll grant that it seems daunting, but if you stick to a something simple to start, you'll get something working in a few days at most. In a few months, you'll have built it up to something like what you're looking for. Good luck.
To the final part of your question:
It seems that you don't know how executables are made from code. People haven't messed with hex in their compilers since the 80s, and hopefully not much even then.
Basically, after parsing the code, you go through a series of steps which make the code progressively simpler. At the end of that, you have something that is quite close to assembly. You then generate assembly, and the assembler and linker conspire to make it into an executable.
The Visual Basic .NET compiler is shipped for free as part of the .NET Framework - you don't even need the SDK or Express Editions. The compiler for VB (and C#) is located at c:\windows\microsoft.net\framework[version]\vbc.exe (or csc.exe for C#). Therefore, any computer which can run a VB.NET program can compile one. The .NET Framework also includes the System.CodeDom namespace which provides a way from within a program to compile a program, either from a document model or from a string (or file) into a .NET assembly (.exe or .dll) and generate code in both VB and C#.
Regards,
Anthony D. Green | Program Manager | Visual Basic Compiler
You create a compiler for vb.net the same way you create any other compiler. You need a lexer/parser. Entire books have been written on this topic, the most famous probably being The Dragon Book.
To provide a definitive answer: No, you cannot create a decent compiler that will generate an executable file using Notepad. You need a compiler to convert from human-readable text into the machine language (assembly or IL) that a linker or interpreter can then execute.
You can try checking out my tutorial at http://www.icemanind.com
It is a tutorial on creating your own virtual machine and assembler, written in 100% C#.
Cyclone, I'm wondering exactly what are you trying to achieve? You say "the exact purpose of what I wish to do is rather hard to explain" and "essentially, the user inputs code, they get a .exe".
If you just want the user to be able to enter code and then execute it, you might consider an existing scripting language. VBScript is built into Windows and the language is fairly similar to VB.Net, or there are various excellent free languages you can download like Python.
If the user really needs to be able to create a .exe - I think it's likely scripting might do - then why not use an existing free compiler like FreeBasic, or even Visual Basic.Net Express Edition.
I am making a tutorial for that in my website, http://dgblogs.weebly.com. It is written with C# and you can create your own computer programming language!
You will never see this syntax in my tutorials:
Console.Readline();
My website is currently offline by now so, GOOD LUCK!
Thanks,
DgBlogs
Im quite shocked that this question was never fully answered ; Recently i came across some tutorials on the subject of developing a programming language from scratch https://www.youtube.com/c/DmitrySoshnikov-education/playlists
Although the person uses Java Script the technique used for creating the tokenizer and the parser to consume the output from the tokenizer producing the AST for the transcribed language which i would consider to be GOLD! ...
Another tutorial or person https://youtube.com/playlist?list=PLSq9OFrD2Q3DasoOa54Vm9Mr8CATyTbLF
Toby Ho! Has also produce various methods using the Nearly parser (plugin) to build a language much easier but not a Pure code coder like myself(does not like extensions to do the work which i can do myself)....
https://github.com/spydaz/SpydazWeb-AI-_Emulators
I was able to do some different experiments designing a stack machine (runs mini assembly language). for my "Toy" Programming language(basic) could be executed on. (the VM) - Using Visual Basic(My personal Lang - I think in VB)
Since revisiting the tutorials ;
https://youtube.com/playlist?list=PLRAdsfhKI4OWNOSfS7EUu5GRAVmze1t2y
Immo Landwerth! Had a few more experiments This time with C#
A bit more Spaghetti to mull over; but actually revealing (after knowing a lot more);
Yes IT is possible to design a Compiler / VM with VB.net Quite easily ... without external tools .
For myself as an AI developer (CONVERSATIONAL AI / NLP) i was interested in building a compiler for the English language if it would be possible to use the technique for parsing syntax trees and building syntax trees from text using the Tokenizer/Parser to AST Method , as well as designing the transpiler to allow for the syntax tree to be used for translation to other languages. as with today's programming languages merely being a Higher lever language interfacing with a low level(VM) language. in-fact we should be developing more natural language - programming languages and dispelling the more cryptic languages such as C# (Lol) and Java and Go and the like (so many brackets and semi colons / tabs etc - truly not needed!) and that is to say that we programmers still think in code! the journey as a AI developer crosses many domains. forces many off topic research pathways .. So Again a big YES! and we Still could say that ANy programming language can be used to create another programming language it just depends on which language you "THINK IN" .... hence not having too many languages using (i understand most programming languages - but i will always think in VB)...

calculus engine in vb?

is there an easy to use library or engine for .NET that does calculus?
I posted an early version of some code I used in one of my classes in an answer to this thread:
Generated methods for polynomial evaluation (my answer includes classes for symbolic differentiation)
If I know exactly what you're looking for, I could try to post an updated version.
Google is suggesting you look through Wikipedia's list of free libraries that can do automatic differentiation, and see if any have a .NET or COM wrapper. EDIT: High-Performance Mark has pointed out that it appears you need symbolic differentiation, in which case these libraries won't help.
If you are keen, you possibly could create a .NET wrapper for one of the C++ libraries.

Is it possible to use registration-free COM with HTA applications?

Since HTA applications are hosted within MSHTA.exe how does one provide a manifest? Plus I assume providing a MSHTA.exe.manifest could potentially break other HTA apps?
On Vista+, MSHTA.exe has an embedded manifest, which takes priority over external manifests, so your suggestion is not an option.
On XP/2003, yes, your suggestion would work, although it would be bad form, as is dropping files in System32 to modify the behavior of a system binary (especially make sure that any registration you put in the manifest are objects you are the only one to care about).
The proper solution, available on Win2003 and above, is to use the Microsoft.Windows.ActCtx object to instantiate your object given an explicit manifest reference.
For example:
var actCtx = WScript.CreateObject("Microsoft.Windows.ActCtx");
actCtx.Manifest = "myregfree.manifest";
var obj = actCtx.CreateObject("MyObj");
Perhaps, if this must work on XP as well, a path you may take is a combination of both solutions.
Edit: My answer is wrong, but I'll leave it here to avoid any similar wrong answers :)
If you question is can you access a COM object without registering it on the machine, then I think the answer is a tentative yes. However the work you would need to do would be substantial and would mean implementing a lot of the low level code that most development tools provide for you as a matter of course (Delphi, .NET, JAVA). You would need to interface with the dll directly (like you would a normal dll ), query its interfaces and call your methods.
If you have C, C++ knowledge, the way COM is accessed from these languages would give you some pointers.
Sorry I cant be of any more help.