|
Hi
I write a sound (*.wav) file, but when I want to play the file with sndPlaySound I get a little blurp from the PC speaker. The particuler file is played with other applications, and other files play fine in my program. The file is closed before I play it. What is wrong?
|
|
|
|
|
what options are you using?
you can also try the PlaySound function
|
|
|
|
|
Joshua Nussbaum wrote:
what options are you using?
??
I've tried PlaySound, same effect.
|
|
|
|
|
what are you sending as the second parameter to sndPlaySound?
|
|
|
|
|
Joshua Nussbaum wrote:
what are you sending as the second parameter to sndPlaySound
at the moment it's:
sndPlaySound("c:\\myKlanke\\DieSin.wav",SND_NOSTOP | SND_ASYNC);
|
|
|
|
|
have you tried it with just SND_ASYNC?
or try SND_SYNC
|
|
|
|
|
Joshua Nussbaum wrote:
have you tried it with just SND_ASYNC?
or try SND_SYNC
just tried both, still same result. Maybe I should just try different flag settings...?
|
|
|
|
|
can you run your code on a different computer, just to illiminate the possiblity of a hardware or driver issue.
|
|
|
|
|
Can that really be an issue? I need sndPlaySound to work on this computer!
|
|
|
|
|
I need to write some code that kills a process.
I know I can use FindWindow to get the HWND of the window, but how do I get the processID of that HWND?
Does anyone know of a Windows API function that does this?
UPDATE: you can ignore this post, I found the answer, theres a function GetWindowThreadProcessId(), its exactly what I was looking for!
|
|
|
|
|
I have done two classes, CTcpServer and CTcpCLient. I think they are self explained!?
In CTcpServer's Bind() method I get an error when I pass a dotted IP string instead of a DNS. It says "Memory cannot be read" or something...
String is a typedef char*
EndPoint is a structure that looks like this:
struct EndPoint
{
String host;
int port;
}
void CTcpServer::Bind(EndPoint ep) const
{
if(IsSocketOK() == 0)
{
throw CSocketException(WSAGetLastError());
}
EndPoint endpoint = ep;
sockaddr_in config;
config.sin_family = AF_INET;
config.sin_port = htons((u_short)endpoint.port);
if(endpoint.host == NULL)
{
config.sin_addr.S_un.S_addr = INADDR_ANY;
}
else
{
if(inet_addr(endpoint.host) == INADDR_NONE)
{
LPHOSTENT hostentry = gethostbyname(endpoint.host);
config.sin_addr.S_un.S_addr = *((unsigned long*)hostentry->h_addr);
}
else
{
String ip = inet_ntoa(*(LPIN_ADDR)*(endpoint.host));
config.sin_addr.S_un.S_addr = inet_addr(ip);
}
}
if(bind(m_ServerSocket, (sockaddr*)&config, sizeof(config)) != 0)
{
throw CSocketException(WSAGetLastError());
}
}
I want it possible to write either a DNS or dotted IP.
What is wroooong!!!
I'm tired, good night!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I do it like this and i dont have any problems passing IP or DNS names..
hostent *pHost = gethostbyname(strDns);
if ( pHost != 0 )
{
sockaddr_in addr;
memset( &addr, 0, sizeof(addr) );
addr.sin_family = AF_INET;
memcpy( &addr.sin_addr, pHost->h_addr, pHost->h_length );
strAddress = inet_ntoa(addr.sin_addr);
}
|
|
|
|
|
So if pHost == 0 there is IP in dotted format?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Greetings,
I have a program in which I spawn a process (AcroRd32.exe with the proper parameters) and I want to wait until it has finished writing a file and then close the process. (I am "printing" to a file.)
I know that I can poll the file's size and wait for it to stop growing for some arbitrary time, but this is unsatisfactory for obvious reasons. It seems like the OS knows when a file gets opened and when the file handle is closed. Is there an easy way, given the full pathname to the file, to detect when a file handle gets closed?
I vaguely recall that there was some Win32 API that might help do this but I cannot find it. I really have searched for it, but I guess I'm not using the right keywords!
Thanks for any pointers.
-- Harold
|
|
|
|
|
Why not just wait for the spawned process to finish? You can do this with CreateProcess() and WaitForSingleObject(). If you want specific code let know.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Oh, would that it were so easy!
I am spawning something like:
AcroRd32.exe /n /t "PSPrinter" "HP LaserJet 5000 Series PS" "filexyz.pdf" "filexyz.ps"
to print a PDF file to a Postscript file. Unfortunately, AcroRd32.exe doesn't exit after doing this. It just sits around, using up resources.
And removing the /n doesn't help. Sigh...
But thanks for the suggestion. Ordinarily that would be the clear winner.
|
|
|
|
|
Possibly there's a neater way using some functions from the Shell library, but the following hack should work: Keep trying to open filexyz.ps in non-create, write mode periodically until you succeed. Then you know AcroRd32.exe is done.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Sounds promising, assuming that AcroRd32.exe normally locks its output file (or the OS does this automatically). I'll give that a try and report back (tomorrow, probably).
Thanks!
|
|
|
|
|
Harold Bamford wrote:
Oh, would that it were so easy!
Yep.;)
I'd like to think AcroRd32.exe locked the file it was printing to. If it does then you could try opening it for write access from time to time and when the open succeeded you'd be away.
There is a Win API FindFirstChangeNotification() which would be worth looking at, but in this case I don't think it will help. See: http://www.codeproject.com/file/filewatch.asp[^]etc.
Also have a look at www.sysinternals.com (seems to be down at present). They have a program called called something like FileWatch which should provide a solution.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Well, I tried it and the method suggested by you and Joaquín M López Muñoz worked perfectly. On the off-chance that AcroRd32.exe creates an empty file before writing to it, I added a check for a non-zero length file, but basically the technique works.
Thanks to both of you!
|
|
|
|
|
Any ideas on how to cleanly check a temperature called temp and a
temperature delta called tempdelta without a gluge of numerous if then
statements?
In other words how clean can you make a piece of code that mointors a temp
at certain intervals (say 1 minute) and performs an action (say sends an e-mail) if that temp is reached. It then does not do anything again until the temp falls below the tempdelta value.
Any ideas here, any samples? Know of any exting on the net?
Thanks very much,
Doug
|
|
|
|
|
Some if s and then s are inevitable. Maintain a bool variable (let's call it trigger ) set to true when the temperature rises above (or equals) temp and to false when it goes below tempdelta . The sending of the email will only be done when trigger was not previously true .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Any ideas on how to cleanly check a temperature called temp and a
temperature delta called tempdelta without a gluge of numerous if then
statements?
In other words how clean can you make a piece of code that mointors a temp
at certain intervals (say 1 minute) and performs an action (say sends an e-mail) if that temp is reached. It then does not do anything again until the temp falls below the tempdelta value.
Any ideas here, any samples? Know of any exting on the net?
Thanks very much,
Doug
|
|
|
|
|
I know I need a boolean variable. Anything more specific on what this might look like.
Thanks,
Doug
|
|
|
|
|
Hello,
I am trying to custom draw my tree control.. I am having problems figuring out what item in the tree is currently being drawn each time the Custom draw function is called..
I want to match the text in the item being drawn agains a string inside a structure which is inside an array.. The only way I know of to do this is m_array.GetAt(iItem) if I do this I need to know what the number of the item i am drawing is..
any ideas?
|
|
|
|