Is there any more documentation on WordBasic's FilePrintSetup? - vba

I found the WordBasic.FilePrintSetup function when I was searching for a way to change Word's printer without changing Windows' default printer.
Unfortunately I could not find any real documentation on FilePrintSetup, even the parameters I found with Google aren't officially documented. (Printer and DoNotSetAsSysDefault)
So do you know of any documentation? Or do you know additional parameters which are supported by FilePrintSetup? (I'm especially interested in setting the tray/paper bin)
EDIT: I found out that the paper bin can be selected with FilePageSetup, an equally undocumented function. So if you have information about this function, I'd appreciate them, too :)

The online help documents the equivalent VBA for WordBasic functions/methods. These are read-only though.
http://msdn.microsoft.com/en-us/library/aa264153(office.10).aspx
Edit: ActiveDocument.PrintOut allows you to select a tray for first and following pages.

Note that the printername parameter of the fileprintsetup method is case-sensitive. XP and Win7 don't store server\printernames the same way so you may find a problem when upgrading OS

The previous reply is wrong. ActivePrinter DOES change the system default printer. Microsoft's documentation clearly states this.

Related

EFI format string reference

Ok, i'm sorry i have to put this up here, but i seem to be unable to find the information i'm looking for. Could someone please point me to some reference documentation about EFI "printf" format reference? I mean it's not like regular printf, as it supports %g as GUID, and prints a question mark for %llu. My best Google-bet was "efi" "print" "format" reference "%g" "%s" "%a" "%d", but it did not gave any usable results. Other search terms came up with some color settings of some printers. What did i do wrong? How can anyone find this info? Thanks.
The flags are described in the PrintLib.h file.
You can find it here: https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Library/PrintLib.h.
EDIT:
The link above is valid if you use EDK2 for building you programs.
The flags when building with gnu-efi are described in the print.c file.
You can find it here (search for function _Print): https://sourceforge.net/p/gnu-efi/code/ci/master/tree/lib/print.c

How does GetProfileString function look for values in the registry?

I was trying to get the default printer through VBA and I came across the Windows API GetProfileString function:
GetProfileString documentation
On one website I found a working example that retrieves the printer name:
returnedChars = GetProfileString("Windows", ByVal "device", vbNullString, printerName, Len(printerName))
The site I linked states that on Windows Server 2003, Windows XP and Windows 2000 (and later versions as well, I assume - the documentation probably isn't up-to-date) the values that GetProfileString return may be taken from the registry if certain conditions are met. I opened the Registry Editor and found the correct section - ...\IniFileMapping\win.ini\Windows. To my surprise, there is no key named device. I re-read the documentation a couple of times, but it didn't help. I don't have a corresponding section in my win.ini file.
Can anyone explain how this function exactly works? It looks like it could come in handy in numerous situations, so it would be nice to know how to use it properly.
This function is one giant backwards compatibility shim. The idea is for legacy code to continue working by picking up values that were moved to the registry when Windows moved from 16-bit to 32-bit.
The documentation makes this pretty clear:
Note This function is provided only for compatibility with 16-bit Windows-based applications, therefore this function should not be called from server code. Applications should store initialization information in the registry.
The message is clear. Do not use this function.
You ask how the function works, when it reads from the registry. That is covered in some detail by the documentation and I don't think there's much to be gained by trying to re-phrase that documentation.
It would be nice to know how to use it properly.
Use the function properly by never calling it!

Change dwm colorization - Windows 7

I'm currently trying to write a program in VB.NET which fluidly changes the DWM window colorization colors in Windows 7.
I first tried to edit Registry values directly, but I had to restart the UXSMS service. This solution was unsatisfying, because of the toggle of the taskbar.
I'm now searching for a function in a DLL such as user32.dll or themecpl.dll which can reproduce the behaviour of control panel when setting the window color.
I'm now on IDA, searching for the adquate function (CColorCplPage::SetDwmColorizationColor seems good!). If anyone has one, please share it!
(If anyone need screens or code, please ask. Sorry for my poor English.)
Your first attempt failed because manually editing the Registry is never the correct way to change system settings. As you found out, lots of Windows components (and other applications!) read those configuration values once and cache them, preventing your changes from being propagated. Another problem (and you'd be surprised how often I see this) is applications that attempt to muck around in the Registry generally end up corrupting things.
Instead, you should call the documented API to change the settings. There's almost always a documented way of doing this, and if there isn't, well then you shouldn't be doing it.
This appears to be one of those cases. There's a documented DwmGetColorizationColor function, but there's no corresponding DwmSetColorizationColor function, as one might expect.
The reason is that the user is supposed to be the only one who can change their colorization settings, not other applications. You might promise not to abuse this, and to only make such changes at the user's explicit request, but not all applications can be trusted to do this. Lots of people would use it maliciously, so these functions have not been documented and exposed.
But as usual, if you press on, you can usually find an undocumented way of doing things. The problem with using undocumented functions is that there's no guarantee they'll work or continue to work. They've been intentionally left undocumented because they're liable to change on new versions of Windows. You should only use them at your own risk.
In this case, if you use a program like DumpBin to obtain a list of all the exported functions from the DWM DLL (dwmapi.dll), you'll see a number of undocumented exported functions.
The ones you're interested in are DwmGetColorizationParameters and DwmSetColorizationParameters. Both of these functions take a COLORIZATIONPARAMS structure as an argument that contains the values they need.
So, you need to reverse engineer these functions and obtain the appropriate definitions. Then, you can call the DwmGetColorizationParameters function, passing in a COLORIZATIONPARAMS structure to obtain the current configuration settings; modify the member of the structure that contains the current colorization color; and then pass that modified version of the structure to the DwmSetColorizationParameters function.
Did I mention that I don't recommend doing this?

How do I Enable pasting a password into a NSSecureTextField?

For some reason some users of my application have to paste content into a NSSecureTextField , mostly because they're using tools to manage/generate their passwords and they can't easily type them. I've been trying to figure out a way to enable this, use another component with the same behavior that would be able to accept pasting or any other way to allow this. All hints are welcome.
It's also interesting that the Apple provided docs say that cut and copy are not possible, but doesn't say anything about pasting.
In recent versions of Mac OS X (I believe in 10.5 forward) pasting is allowed. You don't have to do anything as it is available by default. For older versions of OS X it was prohibited. If you take a look at the revision log for the documentation of NSSecureTextFieldCell it states:
2007-10-31 Removed the statement that
pasting is not allowed

Where can I browse the sourcecode for libc online (like doxygen)

Sometimes I want to look up the implementations of functions in the stdlib, I've downloaded the sourcecode, but it's quite messy.
Just greping is not really suitable because of the many hits.
Does anyone know a webpage doxygen style that has the documentation.
The same goes for the linux kernel.
Thanks
You should check if your distribution is using the vanilla GLIBC or the EGLIBC fork (Debian and Ubuntu have switched to EGLIBC EDIT: they switched back around 2014).
Anyway, the repository browser for GLIBC is at http://sourceware.org/git/?p=glibc.git
http://code.woboq.org/userspace/glibc/, posted by #guruz below, is a good alternative.
The source is a bit complicated by the presence of multiple versions of the same files.
How about this for libc documentation? And perhaps this for the kernel? There is also Google Code search; here is an example search.
More on Google Code Search You can enter search queries like this: package:linux-2.6 malloc for any references to malloc in the linux-2.6 kernel.
Edit: Google Code search is now shut down. But you can access the git repo at http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git and it has search as well.
You can try http://code.woboq.org/userspace/glibc/
It has nice navigation/hilighting similar to an IDE.
To help navigate the source to glibc, perhaps try something like ctags or cscope?
Note: I get dumber every time I look at the glibc source, so please be careful! :)
If you are using GNU C (glibc), the functions (beyond the GNU extensions) follow the POSIX standard as far as their arguments, implementation, failure and return values. If you want to peek under the hood of static members, you'll have to look at the code.
Every push (that I can remember) to try and adopt something like Doxygen for glibc was rejected for the following reasons:
Redundant, POSIX already documents almost everything thats exposed, as well as man and info pages.
Too much work initially
More work for maintainers
As far as the kernel goes, Linux does use a system very similar to Doxygen called Kerneldoc.
You can also get actual Doxygen-generated docs from http://fossies.org/dox/glibc.