Download Programming with lcc-win
Transcript
FAQ
373
2.22.25 How can I control the task bar under program control?
You can control the state of the task bar or query the characteristics using the SHAppBarMessage API. This is a complex API that allows you to change where the tasklbar is localted,
whether it is automatically hidden, etc. For instance, this small program will show you if the
task bar “auto-hide” feature is on or off:
#include<shellapi.h>
#include <stdio.h>
int IsTaskbarAutoHideOn(void)
{
APPBARDATA d;
d.cbSize = sizeof(APPBARDATA);
return SHAppBarMessage(ABM_GETSTATE, &ABData) & ABS_AUTOHIDE;
}
int main(void)
{
printf("Taskbar autohide");
if (IsTaskbarAutoHideOn())
printf(" ON");
else
printf(" OFF");
printf("\n");
}
2.22.26 How to erase a file into the recycle bin?
When you erase a file within a program, the deleted file doesn’t appear in the recycle bin. This
can be annoying if you want to undo this operation of course.
The solution is to use the API SHFileOperation with the flag FOF_ALLOWUNDO. Here is a
small program that does all this for you. Compile with -DTEST to have a standalone program
that will accept command line arguments, or without it to have just the Recycle function that
will erase a file to the recycle bin.140
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <direct.h>
#include <shellapi.h>
//////////////////
// Send a file to the recycle bin. Args:
// - full pathname of file.
// - bDelete: if TRUE, really delete file (no recycle bin)
//
int Recycle(LPCTSTR pszPath, BOOL bDelete)
{
// Copy pathname to double-NULL-terminated string.
140.This program is based on a similar program published in MSDN magazine 2001. In the comments for
that program I found the following:
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
Related documents
Programming with lcc
Programming with lcc-win32
C-Tutorial
Manuel d`utilisation de Version 1.3
IOTech Personal488 DOS and Windows3.X User Manual
Platinum Spot III User Manual ver 1
WinCE manual for OEM - Future Design Controls
Cygwin User's Guide
Cygwin User's Guide
Cygwin User`s Guide
Extending ColdFusion with CFX