|
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?
|
|
|
|
|
I can do what I want if I could figure out a way to get a count of sub items... like
Friends
Joe
Jack
Tom
George
Employees
Doug
Sub items = 5
|
|
|
|
|
I am trying to launch a webpage when a user hits a special key to end the screen saver. The problem is when I use CreateProcess, ShellExecute, or ShellExecuteEx the newly created ie window opens, then closes because my screen saver exits. It doesn't do this when the saver is run by clicking on it in explorer though, or when debugging. It only closes the newly created process when it is activated by windows as a normal screen saver.
What special thing is windows doing to a .scr file when invoked by the system timeout that its not doing to it when you launch it by clicking on it?
Or is there some way I can defer the opening of the browser to another process, such as the desktop window? So then the system won't close it when my saver exits?
I think it may be because the saver is running under a system context when started via the timeout, but when I click on it directly it is run under my user logon context, so maybe I have to use CreateProcessWithLogonW?
Thanks for any help
|
|
|
|
|
mediamaster40 wrote:
I am trying to launch a webpage when a user hits a special key to end the screen saver. The problem is when I use CreateProcess, ShellExecute, or ShellExecuteEx the newly created ie window opens, then closes because my screen saver exits.
Are you 100% sure this is the case? Depending on OS and options it could very well be that IE is still running but on another desktop, namely the secured desktop that the screensaver used.
First I'd suggest you really verify with Task Manager that IE isn't running.
If it is, you must redirect it to the default desktop on the default Windows Station (WinSta0). This is sort-of documented in an MSDN article by Matt Pietrek (when he created the equivalent of RunAs for NT4).
If it isn't running, then something must have "killed" it, and about the only thing I can come to think of to see what's happening is that you create a dummy Windows app that logs just about everything that happens to a file (plain ol' printf debugging ).
|
|
|
|
|
Yes I am sure IE is not runnning, when the saver exits, the IE process is spawned and you see it in the task manager for a second, then you see the browser pop up and go to the page, then my saver cleans up and exits, then the system kills the IE process.
Thanks for the tip, but I have already tried using "winsta0\\default" and it didn't do anything.
Here is the code I am using:
PROCESS_INFORMATION ProcessInfo; //This is what we get as an [out] parameter
STARTUPINFO StartupInfo; //This is an [in] parameter
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
StartupInfo.cb = sizeof StartupInfo ; //Only compulsory field
if(CreateProcess(NULL, cmdLine, NULL,NULL,FALSE,0,NULL,NULL,&StartupInfo,&ProcessInfo))
{
CloseHandle(ProcessInfo.hThread);
CloseHandle(ProcessInfo.hProcess);
return true;
}
else
{
MessageBox(NULL, errorString, "Error Opening Web Browser", MB_OK);
return false;
}
|
|
|
|
|
I have a program that I have been developing under VC++ 7.0. When I try to run the program on a machine that doesn't have Visual Studio.NET it says that it cannot find mfc70.dll. I have set the active configuration to Release but it still doesn't work. Is this just a bug on the the Beta 2 version or am I just doing something wrong. Any help appreciated.
Brad Jennings
|
|
|
|