|
thanks sir
but actually i have no idea about this
so can u give me some other example for help
thanks
|
|
|
|
|
p_ wrote: so can u give me some other example for help
But the sample is already there in the link I provide.
The cd drive can be ejected and inserted using the DeviceIoControl() function. For eg if you want to eject the drive the below code will do
DeviceIoControl(
(HANDLE) hDevice, // handle to device
IOCTL_STORAGE_EJECT_MEDIA, // dwIoControlCode
NULL, // lpInBuffer
0, // nInBufferSize
NULL, // lpOutBuffer
0, // nOutBufferSize
(LPDWORD) lpBytesReturned, // number of bytes returned
(LPOVERLAPPED) lpOverlapped // OVERLAPPED structure
);
And for inserting change the flag to IOCTL_STORAGE_LOAD_MEDIA
|
|
|
|
|
sir i use this code on button but it does not work
DWORD bytesreturned;
DWORD IOCTL_STORAGE_EJECT_MEDIA;
void * hDevice;
DeviceIoControl(
hDevice, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0,
&bytesreturned, NULL );
thanks
|
|
|
|
|
p_ wrote: void * hDevice;
Now you are passing an invalid value as hDevice.
see the below code in the above link.
HANDLE OpenVolume(TCHAR cDriveLetter)<br />
{<br />
HANDLE hVolume;<br />
UINT uDriveType;<br />
TCHAR szVolumeName[8];<br />
TCHAR szRootName[5];<br />
DWORD dwAccessFlags;<br />
<br />
wsprintf(szRootName, szRootFormat, cDriveLetter);<br />
<br />
uDriveType = GetDriveType(szRootName);<br />
switch(uDriveType) {<br />
case DRIVE_REMOVABLE:<br />
dwAccessFlags = GENERIC_READ | GENERIC_WRITE;<br />
break;<br />
case DRIVE_CDROM:<br />
dwAccessFlags = GENERIC_READ;<br />
break;<br />
default:<br />
_tprintf(TEXT("Cannot eject. Drive type is incorrect.\n"));<br />
return INVALID_HANDLE_VALUE;<br />
}<br />
<br />
wsprintf(szVolumeName, szVolumeFormat, cDriveLetter);<br />
<br />
hVolume = CreateFile( szVolumeName,<br />
dwAccessFlags,<br />
FILE_SHARE_READ | FILE_SHARE_WRITE,<br />
NULL,<br />
OPEN_EXISTING,<br />
0,<br />
NULL );<br />
if (hVolume == INVALID_HANDLE_VALUE)<br />
ReportError(TEXT("CreateFile"));<br />
<br />
return hVolume;<br />
}
If you specify the drive letter of the drive, te above function will return a handle pass that handle to the DeviceIoControl() function. like
HANDLE hVolume = OpenVolume( "E:" );<br />
OpenVolume( hVolume, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &bytesreturned, NULL );
|
|
|
|
|
Try mciSendCommand() , like:
mciSendCommand(..., MCI_SET, MCI_SET_DOOR_OPEN, ...);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I want to read a Wav file and do some process for each sample.
Is there any standard method parsing .Wav file?
Thanks & Regards,
Suman
-- modified at 22:25 Tuesday 4th September, 2007
|
|
|
|
|
rp_suman wrote: Is there any standard method parsing .Wav file?
As long as you know its format, no.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
What do you mean by "parsing"? Do you want to play it? Extract information from it? Re-encode it? Something different?
Steve
|
|
|
|
|
Yes, i want to read each sample and do reverse, hamming and delay.
Thanks & Regards,
Suman
|
|
|
|
|
If you want to read yourself the data to get the samples and modify them you have to read corretly the header (after that you will find the row data):
http://www.sonicspot.com/guide/wavefiles.html[^]
I don't know if some functions are jet available in C++.
Don't warning, ... it's not hard, I do something similar by myself using Matlab years ago in less then 1 day.
good luck
Russell
|
|
|
|
|
|
When I apply new lines, I feel that there's got to be a more easier and byte consuming way of making new lines. I'm new to the programming scene, so much help is appreciated. Instead of applying cout and endl beside every line, is there a more common and better way of doing this? Please offer advice. Thank you.
Here's my code:
<br />
#include "stdafx.h"<br />
#include <iostream><br />
<br />
using namespace std;<br />
<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
<br />
cout << "'Gone Crazy'" << endl;<br />
cout << "by Alan Jackson" << endl;<br />
cout << endl;<br />
<br />
cout << "Here I am all alone again tonight" << endl;<br />
cout << "In this old empty house" << endl;<br />
cout << "It's hard to learn what you don't think you need" << endl;<br />
cout << "You can't live without" << endl;<br />
cout << "Never leave the sound of the telephone" << endl;<br />
cout << "But ever since you left" << endl;<br />
cout << "I've been gone" << endl;<br />
cout << "Gone carzy, goin' out of my mind" << endl;<br />
cout << "I've asked myself the reasons," << endl;<br />
cout << "at least least thousand times," << endl;<br />
cout << endl;<br />
<br />
cout << "Press the Enter key to continue...";<br />
cin.ignore(99,'\n');<br />
<br />
return 0;<br />
}
|
|
|
|
|
put the text in a file.
read each line of the file in a loop and spit it out onto the console with cout.
Much less typing
|
|
|
|
|
I need to print all my lines on one paper (hw assignment). So I don't think putting the text in a file is optional at the moment. I remember my professor giving shortcuts but forgot what he did. Any ideas?
|
|
|
|
|
Then how about...
Type one line like this:
cout << "" << endl;
Select the line, Ctrl-C to copy to clipboard, Ctrl-V to copy it a couple hundred times.
Navigate to the top line and start typing text between the quotes.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
lol I didn't mean that kind of shortcut. But I think I've figured it out, instead of using endl, I now use \n for new line. But what's the difference between endl and \n? Which should I use for this situation?
|
|
|
|
|
MoboTech wrote: But what's the difference between endl and \n?
endl writes a '\n' to the stream AND flushes the stream.
You could do cout.flush(); after you've written the lines of text.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
MoboTech wrote: But what's the difference between endl and \n?
In a word...caching.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
void cout (char* szMsg)
{
cout << szMsg << endl;
}
cout("abc");
|
|
|
|
|
// Lyrics.cpp : Displaying Lyrics.
// Steve Baker
#include "stdafx.h"
char* stuff[]= {
{"'Gone Crazy'"},
{"by Alan Jackson"},
{""},
{"Here I am all alone again tonight"},
{"In this old empty house"},
{"It's hard to learn what you don't think you need"},
{"You can't live without"},
{"Never leave the sound of the telephone"},
{"But ever since you left"},
{"I've been gone"},
{"Gone carzy, goin' out of my mind"},
{"I've asked myself the reasons,"},
{"at least least thousand times,"},
{""}
};
char otherStuff[]={
"\
'Gone Crazy'\n\
by Alan Jackson\n\
\n\
Here I am all alone again tonight\n\
In this old empty house\n\
It's hard to learn what you don't think you need\n\
You can't live without\n\
Never leave the sound of the telephone\n\
But ever since you left\n\
I've been gone\n\
Gone carzy, goin' out of my mind\n\
I've asked myself the reasons,\n\
at least least thousand times,\n\
\n"
};
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int nCount=(sizeof(stuff)/sizeof(char*));
// One way...
for (int i=0;i<nCount;++i) {
cout << stuff[i] << endl;
}
// Another way...
cout << otherStuff << endl;
cout << "Press the Enter key to continue...";
cin.ignore(99,'\n');
return 0;
}
|
|
|
|
|
I am writing an application that runs as a Windows Service to measure user inactivity - for the purpose of timing out applications. How best to do it?
None
|
|
|
|
|
Oops: My bad. I just noticed a similar thread below.
But coming to think of it, I am not particularly interesting in using Mouse/Keyboard hooks since they may affect over-all computer response. Is there a way to tell MS Windows to wake up a certain CALLBACK if the user doesn't input for a certain period of time?
None
|
|
|
|
|
look CWinApp::OnIdle (MFC)
Russell
|
|
|
|
|
Wrong. Did you read the docs to find out what OnIdle() does?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->ßRÅhmmÃ<-·´¯`·.
|
|
|
|
|
brahmma wrote: Wrong
brahmma wrote: Did you read the docs to find out what OnIdle() does?
Did you?
Russell
|
|
|
|