|
As TOOL_CONFIG_STRUCT::Release is inlineable, the client app does indeed inline it and thus uses its heap instead of that of the DLL. Declare this method as virtual and you're done.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks a lot!! This works fine
|
|
|
|
|
HI,
I create an windows service in visual C++ 6.0. To install my service i use following command line :
MyService -install
I want to execute this command by program for exemple by a process or Shellexecute function. It's work well but the black command line window always display.
Is there any way to hide this window ?
Thanks in advance
Cheickna
|
|
|
|
|
If you wish to use ShellExecute
HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
nShowCmd
If lpFile specifies an executable file, nShowCmd specifies how the application
is to be shown when it is opened. This parameter can be one of the following values:
SW_HIDE Hides the window and activates another window.
SW_MAXIMIZE Maximizes the specified window.
SW_MINIMIZE Minimizes the specified window and activates the next top-level
window in the z-order.
SW_RESTORE Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position.
An application should specify this flag when restoring a minimized window.
SW_SHOW Activates the window and displays it in its current size and position.
SW_SHOWDEFAULT Sets the show state based on the SW_ flag specified
in theSTARTUPINFO structure passed to theCreateProcess function by the
program that started the application. An application should callShowWindow
with this flag to set the initial show state of its main window.
SW_SHOWMAXIMIZED Activates the window and displays it as a maximized window.
SW_SHOWMINIMIZED Activates the window and displays it as a minimized window.
SW_SHOWMINNOACTIVE Displays the window as a minimized window. The active window
remains active.
SW_SHOWNA Displays the window in its current state. The active window remains active.
SW_SHOWNOACTIVATE Displays a window in its most recent size and position.
The active window remains active.
SW_SHOWNORMAL Activates and displays a window.
If the window is minimized or maximized,
Windows restores it to its original size and position.
An application should specify this flag when displaying
the window for the first time.
|
|
|
|
|
I would like to know the way to get the size of physical disks (hard disks).
When I use IOCTL_DISK_GET_DRIVE_GEOMETRY, it tells me the size of \\.\physicaldisk0 is 33814126080 bytes = 32247 MB
But actually it is a Maxtor 57GB hard disk, also WIndows Disk Management Tool tells me the size is 55.91 GB.
Could anyone teach me a correct way to get the size of physical disks? Thanks.
BuggyMax
|
|
|
|
|
Does this help???
LPCTSTR lpDirectoryName; // directory name
ULARGE_INTEGER lpFreeBytesAvailable; // bytes available to caller
ULARGE_INTEGER lpTotalNumberOfBytes; // bytes on disk
ULARGE_INTEGER lpTotalNumberOfFreeBytes; // free bytes on disk
lpDirectoryName = "c:";
lpFreeBytesAvailable.QuadPart = 0;
lpTotalNumberOfBytes.QuadPart = 0;
lpTotalNumberOfFreeBytes.QuadPart = 0;
FARPROC pGetDiskFreeSpaceEx;
pGetDiskFreeSpaceEx = GetProcAddress( GetModuleHandle("kernel32.dll"),
"GetDiskFreeSpaceExA");
if (pGetDiskFreeSpaceEx)
{
GetDiskFreeSpaceEx (lpDirectoryName,
(PULARGE_INTEGER)&lpFreeBytesAvailable,
(PULARGE_INTEGER)&lpTotalNumberOfBytes,
(PULARGE_INTEGER)&lpTotalNumberOfFreeBytes);
}
else
{
AfxMessageBox(_T("Error"));
}
|
|
|
|
|
Xander80 wrote:
lpDirectoryName = "c:";
Thanks but "C:" is logical drive. What I need is size of physical disks.
Thanks.
BuggyMax
|
|
|
|
|
BuggyMax wrote:
physicaldisk0 is 33814126080 byte
How do you get that ?
You should multiply : bytes per sector * sectors per track * track per cylinder * cylinders to get your size.
If this does not work, maybe use IOCTL_DISK_GET_DRIVE_LAYOUT to get the partitions and IOCTL_DISK_GET_PARTITION_INFO to retrieve the sizes.
~RaGE();
|
|
|
|
|
Rage wrote:
You should multiply : bytes per sector * sectors per track * track per cylinder * cylinders to get your size.
Yes that huge number (33814126080) is the result of multiplying the four values.
Rage wrote:
If this does not work, maybe use IOCTL_DISK_GET_DRIVE_LAYOUT to get the partitions and IOCTL_DISK_GET_PARTITION_INFO to retrieve the sizes.
What if the disk contains NO partitions?
BuggyMax
|
|
|
|
|
This correctly reports that I have a (roughly) 13GB disk:
HANDLE disk;
DWORD dwNeeded;
DISK_GEOMETRY *geometry;
disk=CreateFile("\\\\.\\PHYSICALDRIVE0",
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if (INVALID_HANDLE_VALUE != disk)
{
geometry = new DISK_GEOMETRY;
DeviceIoControl(disk,
IOCTL_DISK_GET_DRIVE_GEOMETRY,
NULL,
0,
geometry,
sizeof(DISK_GEOMETRY),
&dwNeeded,
NULL);
TRACE(" Cylinders: %I64u\n", geometry->Cylinders);
TRACE(" Media Type: %d\n", geometry->MediaType);
TRACE("Tracks/Cylinder: %lu\n", geometry->TracksPerCylinder);
TRACE(" Sectors/Track: %lu\n", geometry->SectorsPerTrack);
TRACE(" Bytes/Sector: %lu\n", geometry->BytesPerSector);
delete [] geometry;
CloseHandle(disk);
}
|
|
|
|
|
That source code was also what I used. But the values I got were:
Cylinders: 4111 ( I use __int64 already.)
TracksPerCylinder: 255
SectorsPerTrack: 63
BytesPerSector: 512
The result, as you see, is 33GB.
But actually it is a 55.9GB one.
It means amount of cylinders should be 6964.
BuggyMax
|
|
|
|
|
I am showing bar Graph on a dilaog using progress bars. The graph is dynamically updating and this is shown by vayring values of progress bar.
I simply want the dialog to printed on a paper when the user clicks on a certain button on the dialog.
Plz guide me how to do so.
Reply me soon
|
|
|
|
|
I have developed a Dialog based Application.
I am using an ActiveX control. It plays a multimedia file.
Whenever it plays a file, it took a huge amount of memory, because the memory consumption depends on the number of frames contained in the file being played by the ActiveX control.
Now what I like, is to reclaim the memory consumed by the file.
Please can anybody tell me, how to reclaim the memory, because if we are reclaiming the memory it means we know in advance the location in memory we are consuming.
Please I need utmost help in this regard.
The Phantom. ™
|
|
|
|
|
Is your app allocating the memory, or is the ActiveX control doing it?
|
|
|
|
|
The ActiveX control consuming the memory...
The Phantom. ™
|
|
|
|
|
busisoft wrote:
Now what I like, is to reclaim the memory consumed by the file.
The ActiveX control consuming the memory...
Then there's not anything your program can do about it.
|
|
|
|
|
I have a CDialog derived class CMyDlg. I hope the CMyDlg can release itself automatically. To accomplish this, I implement the CMyDlg:: PostNcDestroy as follows:
CMyDlg::PostNcDestroy()
{
CDialog::PostNcDestroy();
delete this;
}
Then, I always call the following code to create an instance of CMyDlg:
CMyDlg* pMyDlg = new CMyDlg;
pMyDlg->DoModal()
I believe that the PostNcDestroy() function will be called eventually if the CMyDlg is ended from the EndDialog(). And there is no memory leak, since *this* is deleted in the PostNcDestroy().
Can anyone confirm me whether my implementation is OK or not?
Thanks in advance.
lauch
|
|
|
|
|
There is nothing wrong in your approach theoretically, but you don't need to do all this. Just create it on the stack and when it goes out of scope it gets destroyed automatically. You only need to create a heap object (which them means you gotta delete it yourself) if you plan on creating a modeless dialog.
Nish
"I'm a bit bored at the moment so I'm thinking about writing a new programming language" - Colin Davies
My book :- Summer Love and Some more Cricket [New Win]
Review by Shog9 Click here for review[NW]
|
|
|
|
|
to Nish,
Thanks for your reply.
For some reasons, I must new the CMyDialog as a heap object and it must be a modal dialog box (which is created by the DoModal() function). Therefore, I decide to delete itself in the PostNcDestroy() specifically. I have tested my program, there is no memory leak. However, do you think my appraoch is safe? or is there probably a side effect in this implementaion?
Lauch
|
|
|
|
|
|
Nish,
Please help.
After EndDialog() is called, the DoModal() is released. I have walked through the MFC source code of the CDialog::DoModal(), I found DestroyWindow() is called in CDialog::DoModal() function, which in turn call PostNcDestroy() which will delete *this* pointer. And then, the code listed below will also be executed:
PostModal();
// unlock/free resources as necessary
if (m_lpszTemplateName != NULL || m_hDialogTemplate != NULL)
UnlockResource(hDialogTemplate);
if (m_lpszTemplateName != NULL)
FreeResource(hDialogTemplate);
return m_nModalResult;
Since *this* is already freed, all member variable, function method and the memory allocated for the above code is supposed to be freed already, I am not sure whether or not it safe. Any hint?
Thanks.
|
|
|
|
|
lauch2 wrote:
I am not sure whether or not it safe.
It's safe, don't worry. When you do your delete you are deleting your dialog object, here they are basically freeing the dialog resource.
Anyway just in case you are still worried, you can move the delete from the PostNCDestroy to just after the DoModal :-
CDlg* a = new CDlg();
a->DoModal();
delete a;
This way you ensure that you delete it only after the call to PostModal from within DoModal.
But seriously I do not think there is any problem right now.
Regards,
Nish
"I'm a bit bored at the moment so I'm thinking about writing a new programming language" - Colin Davies
My book :- Summer Love and Some more Cricket [New Win]
Review by Shog9 Click here for review[NW]
|
|
|
|
|
On second thoughts I suggest that you do this :-
CDlg* a = new CDlg();
a->DoModal();
delete a;
Because if PostModal gets called after you delete the object then it is actually trying to access members of an object that does not exist anymore. This might cause problems as you can guess.
Nish
"I'm a bit bored at the moment so I'm thinking about writing a new programming language" - Colin Davies
My book :- Summer Love and Some more Cricket [New Win]
Review by Shog9 Click here for review[NW]
|
|
|
|
|
Nish,
Another question:
Do you know any messages will send to a dialog subsequently after calling the EndDialog() to triggle the dailog to close itself?
lauch
|
|
|
|
|
If anybody knows how to implement automation function in Visual C++ to copy bitmap that resides on the clipboard to a MS Word documetn. Sounds so simple but I am clueless. Please HELP!!!
|
|
|
|