|
|
hello
I have many questions
1-how a program can run just from cd-rom
2-how a program can have one instance running
3-how can get list of programs instaled in system
4-how can uninstall a program
5-how can set a program in startup list
6-how can search a file in entire system
7-PowerPoint OLE commands
I use c++ Builder but I can use visual c++ 6
Thank You
Astatira
|
|
|
|
|
1- Yes. ( must be certain that you don't write temporary files in the same path as the executable )
2- Yes. ( search this site for examples )
3- Yes. ( don't know the API, but google or MSDN can help you with that )
4- By Clicking on the Uninstall menu item ( or button in the add/remove program control panel.
5- ??? you mean by adding a shortcut of your application to the Startup folder.
6- have a look at FindFirstFile and FindNextFile
7- don't have a clue.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
From the previous answer you can see that what you are asking is possible, as I assume you are aware.
But to ask those here to do this much work for you is unreasonable.
Look around, try to do these things yourself, and when you are unable to figure something out (after trying it yourself) then ask specific questions and show what you have done, code snippets for example.
|
|
|
|
|
rezvan wrote: 7-PowerPoint OLE commands
See MSDN artcle Q169505.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Hi, I made an uninstaller, and I need to delete the uninstaller exe, and the folder where it is.
So I used
MoveFileEx((m_installDir + "UAdmPass.exe"),NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
MoveFileEx, is returning OK but, I rebbot the machine and the file still there...
Any suggestions?
Thanks
|
|
|
|
|
Are you the administrator?
Have a nice code day
|
|
|
|
|
Yeap.
My application needs special permisions to delete a file?
Like when you want to force a shutdown?
|
|
|
|
|
I'm not sure but I think yes. But I need to check.
try with *.bat file as tell David, I think it is better.
Bye
Have a nice code day
|
|
|
|
|
A .bat file is going to be your best bet if you need this on all platforms. There are other solutions, but they are either limited to Windows 9x, or Windows NT, but not both. See here for more.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Check the filename - is there a backslash on the end of m_installDir ?
BTW you can verify this before rebooting by looking in the reg key HKLM\SYSTEM\CurrentControlSet\Control\Session Manager , value PendingFileRenameOperations
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
Come quietly or there will be... trouble.
|
|
|
|
|
Thanks to all for the advise, but I need to be Win ME compatible, so I'll use a .bat file
|
|
|
|
|
You can't use MoveFileEx() on 9x, you have to write a \windows\wininit.ini file that lists the files to delete. I know I've seen an article in MSDN that has code to do that for you.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
I want to see in the TaskInfo2003 somthing more informative, than "thread", when i CreateThread().
And when i create in ms vs2002 mfc application, it`s name represented like "TODO: <file description="">"
|
|
|
|
|
I use the following function to set the name of each thread. Call it at the beginning of your thread function:
void SetThreadName(LPCSTR name)
{
struct {
DWORD dwType;
LPCSTR szName;
DWORD dwThreadID;
DWORD dwFlags;
} thread_name_info;
thread_name_info.dwType = 0x1000;
thread_name_info.szName = name;
thread_name_info.dwThreadID = (DWORD)-1;
thread_name_info.dwFlags = 0;
__try {
RaiseException(0x406D1388,0,
(sizeof(thread_name_info)/sizeof(DWORD)),
(const ULONG_PTR *)&thread_name_info);
}
__except (EXCEPTION_CONTINUE_EXECUTION) {
}
} Note that this works with the Visual Studio debugger. I don't know if it will work with your application ("TaskInfo2003").
Software Zen: delete this;
|
|
|
|
|
Thank you, but it`s really works ONLY with the Visual Studio debugger, not with the process managers
|
|
|
|
|
Hi,
I want to save a bitmap in a file. My funcion is the following code, but this save the a inverted bitmap.
BOOL CDXCaptureDlg::SaveBMP(BYTE *Buffer, int width, int height, long paddedsize, char *bmpfile)<br />
{<br />
BITMAPFILEHEADER bmfh;<br />
BITMAPINFOHEADER info;<br />
<br />
memset ( &bmfh, 0, sizeof (BITMAPFILEHEADER ) );<br />
memset ( &info, 0, sizeof (BITMAPINFOHEADER ) );<br />
<br />
bmfh.bfType = 0x4d42;
bmfh.bfReserved1 = 0;<br />
bmfh.bfReserved2 = 0;<br />
bmfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + paddedsize;<br />
bmfh.bfOffBits = 0x36;
<br />
<br />
info.biSize = sizeof(BITMAPINFOHEADER);<br />
info.biWidth = width;<br />
info.biHeight = height;<br />
info.biPlanes = 1;
info.biBitCount = 24;
info.biCompression = BI_RGB;<br />
info.biSizeImage = 0;
info.biXPelsPerMeter = 0x0ec4;
info.biYPelsPerMeter = 0x0ec4;<br />
info.biClrUsed = 0;
info.biClrImportant = 0;
<br />
<br />
HANDLE file = CreateFile ( bmpfile , GENERIC_WRITE, FILE_SHARE_READ,<br />
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );<br />
<br />
if ( file == NULL )<br />
{<br />
CloseHandle ( file );<br />
return FALSE;<br />
}<br />
<br />
unsigned long bwritten;<br />
if ( WriteFile ( file, &bmfh, sizeof ( BITMAPFILEHEADER ), &bwritten, NULL ) == FALSE )<br />
{<br />
CloseHandle ( file );<br />
return FALSE;<br />
}<br />
<br />
if ( WriteFile ( file, &info, sizeof ( BITMAPINFOHEADER ), &bwritten, NULL ) == FALSE )<br />
{<br />
CloseHandle ( file );<br />
return FALSE;<br />
}<br />
<br />
if ( WriteFile ( file, Buffer, paddedsize, &bwritten, NULL ) == FALSE )<br />
{<br />
CloseHandle ( file );<br />
return FALSE;<br />
}<br />
<br />
CloseHandle ( file );<br />
<br />
return TRUE;<br />
}<br />
Ivan Cachicatari Blog[^]
www.latindevelopers.com
|
|
|
|
|
Ivan Cachicatari wrote: inverted bitmap
It means color inversion, image transposition (like matrix) or other ?
Have a nice code day
|
|
|
|
|
Do you mean it's upside-down?
That's the way the BMP format works, the first row in the data is the bottom line, and so on up to the top.
--
Help me! I'm turning into a grapefruit!
Buzzwords!
|
|
|
|
|
Windows understands normal (upside down) bitmaps as well as "right-way-up" bitmaps - check the MSDN documentation on bitmap headers. As far as I remember, "right-way-up" bitmaps have negative height, so in your posted code, try changing:
info.biHeight = height;
to
info.biHeight = -height;
I use this technique with a StretchDIBits call, and it works there.
Since you are not processing the bitmap data at all, whether this technique works will depend on the application you use to display the bitmap. A "well-behaved" application (conforming to MSDN bitmap standards) will display correctly. A "badly behaved" application will display the bitmap upside down or crash.
Some applications may accept it, some may not! But it's easy to try.
|
|
|
|
|
Hello every one,
Please let me explain my problem neatly.
I am using DLL (without MFC/ATL/WTL)with shared memory and I declared shared memory using
#pragma data_seg(".shared")
directive.
As I am using DLL only for system wide hook, only my application uses it. But my applicaton can be terminated and restatred again (by user). I observed using taskmanager and debugger with step executation when my program calls SetWindowsHookEx(), 8KB memory get used by my application(process). But while termination this 8KB memory doesn't get released. This makes me two problem.
1) If I want to update/change my DLL file by terminating application Windows doesn't allow it. (As my development is going on,I have to do it). Only way to wait for some time or Log off/restart.
2) If my application get restarted 15 times a day, shall application aquire 120KB memory?
How I can release this shared memory? Or reuse last unreleased next time.
How to solve this problem?
First deserve then desire. Let be deserved first.
|
|
|
|
|
When your aplication is closed, YOU MUST UNHOOK THE SYSTEM HOOK ALWAYS!
A system hook takes a lot of system resources, and is to long to explain here why, so unhook it using UnhookWindowsHookEx
Also, in you aplication create a button to hook/unhook your hook, that way you would be able to change the hook dll witout restarting.
Also, you must use a semaphore to check that only one instance of your aplication is running.
System hook's are a bit complicated at the beginning, I suggest you to check the theory in a lot of good articles in here.
Doing this, you shouldn't have more memory or performance leaks.
Good luck
|
|
|
|
|
Thanks for your reply.
Unfortunately it is not useful as I am using UnhookWindowsHookEx already while exiting.
Time of unreleasing DLL from memory get extended if I rerun application after terminating first instance.
Can you mention any links regarding using semaphore.
Thanks a lot.
Shivaji Patil
First deserve then desire. Let be deserve first.
|
|
|
|
|
Quoted:
" If I want to update/change my DLL file by terminating application Windows doesn't allow it. (As my development is going on,I have to do it). Only way to wait for some time or Log off/restart."
Your Unhook process isn't working fine, your hook DLL is still running when you close your application, that's why you never free those 8K.
Try closing all the hooked applications, after your unhook and check if the memory is back.
ABout the semaphore...
// Just one instance
hMutexOneInstance = CreateMutex(NULL, TRUE, "Your program ID");
if (GetLastError() == ERROR_ALREADY_EXISTS)
OnCancel();
if (hMutexOneInstance)
CloseHandle(hMutexOneInstance);
Paste that on your oninitdialog, and that's all.
"Your program ID" is any string you want to use.
Good luck
|
|
|
|
|
Thanks for reply.
Let me check.
First deserve then desire. Let be deserved first.
|
|
|
|