const char* str = (const char*)
// use str as you wish or copy it elsewhere
// free string
We are men. We are different. We have only one word for soap. We do not own candles. We have never seen anything of any value in a craft shop. We do not own magazines full of photographs of celebrities with their clothes on. - Steve
In Win32 you would normaly do hardware enumeration to determine if a modem is attached (search codeproject articles). Another method, is to send an AT command out the known ports and check the result (string or code) that is return, if any.
I got stuck on a project where it is needed to tell the path name of the program(if any) that is associated with a particular file type, i.e. I should be able to get "c:\\windows\\system32\\notepad.exe" from ".txt". I checked in HKEY_CLASS_ROOT but not every entry there has a "shell\\program" key so I think there must be other ways to retrieve the associated program...
The return key on my laptop doesn't work.How do I map the right shift key as the return key. In other words, when I press the right shift, it appears a return in the program.
This is urgent, thanks a lot.
I have been trying to send an event from a DLL (Dynamically loaded) to a GUI application to display text.
I use shared memory for the transfer of data, also in this shared data area in the handle for this event.
In the DLL I
m_pMsg->hGlobalWriteEvent = CreateEvent(NULL, // no security attributes
FALSE, // manual-reset event
FALSE, // initial state is signaled
"CSLDisplayData" // object name
Note m_pMsg is a pointer to the shared memory area.
Then I send the event:-
// Signal GUI to process this request
Now in the GUI I have a thread waiting on this event.
if (::WaitForSingleObject(ThreadData->m_pMsg->hGlobalWriteEvent, INFINITE) == WAIT_OBJECT_0)
But this event in the GUI is never fired.
Note I can create and send an event to the thread from the GUI but not from the DLL.
I have created a list control with 7 columns and need the user to be able to adjust the width of the columns. This all works fine unless the user adjusts a column width so that a scroll bar is needed. When this is done part of the window refuses to redraw automatically leaving grey patches in place of the data. Running RedrawWindow() (from a button) corrects the problem however I cannot find a message that is always sent when the user completes adjusting a column to run RedrawWindow() automatically. I have tried HDN_ENDTRACK and LVN_COLUMNCLICK plus a couple of less likely candidates all without effect.
Which version of comctl32? Updating it (by installing latest IE) might fix it...
I remember such problems to. Either there was a flaky comctl32 version out, or it happens only in some "strange" scenarios. Can you reproduce the problem in a simple dialog based application with only the list box on it?
If you have the name of the process, and that process is not you, you must either search for a window you know that process created, and get the process ID from that, or, if you only have the name of the process, you need to use the PSAPI/ToolHelper API to enumerate all running processes, look at each one's name, check if it matched, and if so, grab it's process ID.
Bare in mind PSAPI only works with NT/2k/XP so if you want a cross platform soulition, use ToolTip - see the file Tlhelp32.h in the platform SDK for a statring point- but you want something like this which terminates a process given a name BOOL CTestEnvKillerApp::InitInstance()
I'm searching for code or just the name of the windows api function that can turn _only_ the screen (not the whole computer) into standby mode, in other words, turn it off, until the mouse gets moved or a key gets pressed.
I found out that there's a (user configurable) display idle timer, however, I haven't found a way to manipulate this timer programmatically.
There are actually quite a lot of functions in the windows api related to power managment, but seemingly not one to turn only the screen off...
Create a power scheme where USER_POWER_POLICY.VideoTimeoutAc is set to 1 (second). Save the policy by calling WritePwrScheme(). Then call SetActivePwrScheme() to set the current power scheme to the one that you just created. This is just a high-level overview, but hopefully you get the gist enough to fill in the blanks.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
Yeah thanks I successfully used your description to send my screen into darkness after one second.
But (there's always one ) theres the problem of waking up again. If I don't move the mouse around continously the screen blankens immediately again (no surprise, timer is still set to 1 second).
So I thought, well, why don't wait the second until standby mode kicks in, and then write the old timer back? I use Sleep() for this, but the problem is, after Sleep() returns, the system thinks that it should awaken itself again and the screen turns on.
So, I need a way to wait this second and write the old scheme back WITHOUT letting the system think it should wakeup.
If a computer is suspended/hibernating, does that affect then length of time a process will sleep for?
If a process is told to Sleep () for 1 hour and after half an hour the computer is put into hibernate for 2 hours, when it starts back up again and Windows resumes, does the process still have half an hour to Sleep (), or is its Sleep () time up (having effectively slept for 2 1/2 hours already)?