 |

|
SORRY! I just re-read the subject line...
The only thing I can think of is that the security options you've OR'd together may need to be modified to include something else.
I'd try the call to SetSecurityInfo with THREAD_ALL_ACCESS to see if that works first.
modified 1 Apr '13 - 11:38.
|
|
|
|

|
I am looking for some code to turn off my Wifi adaptor.
Intel Wifi link
I would like to be able to quickly turn it off and then back on later.
I think it would use these includes and library.
Thanks.
Wlanapi.inc
Wlanapi.lib
WlanOpenHandle
|
|
|
|
|

|
Hi
I'm trying to write automation to a test a web site with C#.
I'm using selenium web driver but it cannot interact with native windows. so i'm using winAPI to control a dialog window.
I am trying to automaticly upload a file by interacting with the Dialog window.
I have managed to get a handle on the window using the following code:
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_CLOSE = 0xF060;
public const int WM_SETTEXT = 0x000C;
private void ChooseFile()
{
int iHandle = FindWindow("#32770", "File Upload");
if (iHandle > 0)
{
}
}
What I need to do next is choose the file to upload and then press OK to approve.
Help will be much appreciated
|
|
|
|

|
It seems like a little wrong thread, but with C++ I'd like this:
HANDLE hEdit=FindWindowEx(iHandle,NULL,"EDIT",NULL);SetWindowText(hEdit,"full filename you need");
SendMessage(iHandle,WM_COMMAND,MAKEWPARAM(IDOK,0),(LPARAM)0);
Or
SetDlgItemText(iHandle,[Edit control ID],"full filename you need");
SendMessage(iHandle,WM_COMMAND,MAKEWPARAM(IDOK,0),(LPARAM)0);
Obtain [Edit control ID] with Spy++, it must be a constant.
|
|
|
|

|
A colleague of mine informed me that he was informed (I love hearsay), by a MS employee/evangelist that there is essentially no Bluetooth stack to work with. This seems quite insane and a very bad move (IMO) by MS... But not shocking.
However I can neither confirm nor deny it. There is nothing that I am seeing on the web that implies this one way or the other.
Note: I am not talking about traditional Bluetooth devices that have set standards that the OS can pair with (e.g. keyboard, mouse, headset etc.). I am referring to a Bluetooth device that would send binary data of some sort
e.g. connect to a sensor using the 4.0 stack or connect to a PAN using 2.1 stack.
Anyone know if this is true or not and have any links to the info?
Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.
|
|
|
|

|
I suspect that what he's referring to comes from this[^].
|
|
|
|

|
While that is useful it does not cover his implications. He implied there is "No way" to connect to a Bluetooth device on RT if it is not one of the standard items (headset etc.) regardless of the Bluetooth integration (i.e. can be USB).
But interesting to note... I have a laptop that has integrated Bluetooth. This implies that internally the bluetooth is actually landing on the USB. I would have expected I²C...
Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.
|
|
|
|

|
Collin Jasnoch wrote: implies that internally the bluetooth is actually landing on the USB
That's kind of what I was trying to point out from that link. That's exactly where the Bluetooth would be landing as that's the "stack" that MS supports.
|
|
|
|

|
Ahhhh.. I see. Good point.
That is quite unfortunate, and a failure IMO. Oh well. Guess the iPads will continue to dominate.
Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.
|
|
|
|

|
I'm trying to handle mouse wheel events in the WndProc function and wrote c++ code that works fine with one mouse that has a fly-wheel. I tried the same code with another mouse and I get endless WM_MOUSEWHEEL events when I move the mouse wheel just one notch.
Anyone know why this is happening?
|
|
|
|

|
Sounds like a possible hardware error. Does it happen in other applications with the "bad mouse"?
One of these days I'm going to think of a really clever signature.
|
|
|
|

|
No, it's not a hardware problem. There's nothing wrong with the mouse
|
|
|
|

|
It seems very odd that one mouse works correctly but the other generates lots of messages. That implies that there is something wrong with the second mouse.
One of these days I'm going to think of a really clever signature.
|
|
|
|

|
no, it works fine. It is definately not hardware. I could be that one mouse is fly wheel and other is not, or it could be that the code I'm using is wrong in someway
|
|
|
|

|
Could it be a "helpful hidden feature" of the mouse-driver?
|
|
|
|

|
Yes, but that would affect all applications, which it clearly isn't.
|
|
|
|

|
No, it would not; some programmers would simply take the first message, and ignore the repeating drivel, just like you would with spurious wm_mousemove messages.
Update the drivers
|
|
|
|

|
Not really. There's no way to tell which are real events and which are the spurious ones. At least, there's no way I know.
|
|
|
|

|
You haven't posted any code or shown what any of the "extra" WM_MOUSEWHEEL events you are getting look like and unfortunately, my crystal ball is in the shop, so you might want to post that kind of information. My guess is that its something in your code, but until I see the messages or your code, I can't really give you any advice beyond that. Darn crystal ball shop, they are taking FOREVER to get my ball fixed.
|
|
|
|

|
how write program paint in win32?
|
|
|
|

|
- Study the C/C++ languages.
- Learn the structure of Windows programs and how to create them.
- Study the Win32 API starting here.
- Decide on whether to use Windows GDI or GDI+.
- Design your application.
- Start coding.
One of these days I'm going to think of a really clever signature.
|
|
|
|

|
You are absolutely right Richard
|
|
|
|

|
First you should study what is win32 programming. If you don't know about win32 programming, then how can coding win32 programs? so first study win32 APIs
http://www.winprog.org/tutorial/
Also see Richards comments
|
|
|
|

|
Hi,
This is an article that can help you:
Guide to WIN32 Paint for beginners[^]
It doesn't explain how to create a Paint program, but how to paint shapes in your form.
In some cases, my signature will be longer then my message...
<em style="color:red">ProgramFOX</em> ProgramFOX
|
|
|
|

|
Follow the Book "Programming Windows 5th Edition - Charles Petzold"
|
|
|
|
|

|
May as well be asking how to skin a cat.
Steve
|
|
|
|

|
I want to playback videos with Microsoft Media foundation with a custom clock.
I am starting with the example found at http://archive.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=mediafoundation&DownloadId=8413[^]
The idea is to replace the clock with one that is driven by UDP packets. The videos will be silent (the audio turned off, preferably not even decoded).
I have stubbed out what I think is a clock replacement, but what I can't figure out is why my calls to GetCorrellatedTime seem to only occur at the start of playback. I expected GetCorrellatedTime to be called by the playback engine repeatedly.... but that's just not happening. Here's the cpp code for my timesource. Note that it doesn't do much of anything yet... it is just a stub.
Any Ideas? Thanks in advance
#include "MFPlayer.h"
#include "TimeSource.h"
HRESULT STDMETHODCALLTYPE UDPClock::GetClockCharacteristics( __RPC__out DWORD *pdwCharacteristics)
{
*pdwCharacteristics = MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ;
return S_OK;
}
HRESULT STDMETHODCALLTYPE UDPClock::GetCorrelatedTime( DWORD dwReserved, __RPC__out LONGLONG *pllClockTime, __RPC__out MFTIME *phnsSystemTime)
{
m_Time = GetTickCount64();
m_System_Time = GetTickCount64();
*pllClockTime = m_Time;
*phnsSystemTime = m_System_Time;
return S_OK;
}
HRESULT STDMETHODCALLTYPE UDPClock::GetContinuityKey( __RPC__out DWORD *pdwContinuityKey)
{
*pdwContinuityKey = 0;
return S_OK;
}
HRESULT STDMETHODCALLTYPE UDPClock::GetState( DWORD dwReserved, __RPC__out MFCLOCK_STATE *peClockState)
{
*peClockState = MFCLOCK_STATE_RUNNING;
return S_OK;
}
HRESULT STDMETHODCALLTYPE UDPClock::GetProperties( __RPC__out MFCLOCK_PROPERTIES *pClockProperties)
{
pClockProperties->qwCorrelationRate = 1000000;
pClockProperties->guidClockId = GUID_NULL;
pClockProperties->qwClockFrequency = MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ;
pClockProperties->dwClockTolerance = MFCLOCK_TOLERANCE_UNKNOWN;
pClockProperties->dwClockJitter = 1; pClockProperties->dwClockFlags = MFCLOCK_RELATIONAL_FLAG_JITTER_NEVER_AHEAD;
return S_OK;
}
HRESULT STDMETHODCALLTYPE UDPClock::GetUnderlyingClock( __RPC__deref_out_opt IMFClock **ppClock)
{
*ppClock = this;
return S_OK;
}
HRESULT UDPClock::QueryInterface (REFIID riid, LPVOID * ppvObj)
{
if (!ppvObj)
return E_INVALIDARG;
*ppvObj = NULL;
if (riid == IID_IUnknown || riid == IID_IMFClock || riid == IID_IMFPresentationClock)
return NOERROR;
return E_NOINTERFACE;
}
ULONG UDPClock::AddRef()
{
InterlockedIncrement(&m_cRef);
return m_cRef;
}
ULONG UDPClock::Release()
{
ULONG ulRefCount = InterlockedDecrement(&m_cRef);
if (0 == m_cRef)
{
delete this;
}
return ulRefCount;
}
HRESULT STDMETHODCALLTYPE UDPClock::OnClockStart( MFTIME hnsSystemTime, LONGLONG llClockStartOffset)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE UDPClock::OnClockStop( MFTIME hnsSystemTime)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE UDPClock::OnClockPause( MFTIME hnsSystemTime)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE UDPClock::OnClockRestart( MFTIME hnsSystemTime)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE UDPClock::OnClockSetRate( MFTIME hnsSystemTime, float flRate)
{
return S_OK;
}
|
|
|
|

|
I am using ExtTextOut to print unicode characters in memory DC. We create font using CreateFontIndirect to print characters in different orientations. When we use GB2312_CHARSET (chinese character set) with lfEscapement/orientation set to 270 degrees the characters are printed in reverse order.
If the character to be printed is 'Chinese', it is printed as 'esenihc'. The same character set works fine if lfEscapement/orientation is set to 0 deg.
The issue is present only in WINCE. The same code works fine in a Win32 application.
I have written a sample application.Find below the code from sample app
CSampView::OnDraw (CDC* pDisplayDC)
{
HDC hDC = CreateCompatibleDC(NULL);
HBITMAP hBmp = CreateCompatibleBitmap(hDC, width, height);
BITMAPINFO biBitmapInfo;
// font size may vary if screen resolution changes
biBitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
biBitmapInfo.bmiHeader.biWidth = 500;
biBitmapInfo.bmiHeader.biHeight = 500;
biBitmapInfo.bmiHeader.biPlanes = 1;
biBitmapInfo.bmiHeader.biBitCount = 1 ;
biBitmapInfo.bmiHeader.biCompression = BI_RGB;
biBitmapInfo.bmiHeader.biSizeImage = 0;
biBitmapInfo.bmiHeader.biXPelsPerMeter = 0;
biBitmapInfo.bmiHeader.biYPelsPerMeter = 0;
biBitmapInfo.bmiHeader.biClrUsed = 0;
biBitmapInfo.bmiHeader.biClrImportant = 0;
biBitmapInfo.bmiColors[0].rgbBlue = 0;
biBitmapInfo.bmiColors[0].rgbGreen = 0;
biBitmapInfo.bmiColors[0].rgbRed = 0;
biBitmapInfo.bmiColors[1].rgbBlue =1;
biBitmapInfo.bmiColors[1].rgbGreen = 1;
biBitmapInfo.bmiColors[1].rgbRed = 1;
CDC *pDC = CDC::FromHandle(hDC);
/*TCHAR szString[255] = {0x0043, 0x0068, 0x0069, 0x006E, 0x0065, 0x0073, 0x0065, 0x003A, 0x0020, 0x96C5,
0x864E, 0x641C, 0x661F, 0x575A, 0x51B3, 0x5426, 0x8BA4, 0x80E1, 0x6208, 0x63A5,
0x62CD, 0x96C5, 0x864E, 0x5E7F, 0x544A };*/
wchar_t szString[255] = _T("Print Test");
PUINT8 pui8ImageContent;
// Create rendering canvas
HBITMAP hBmp1 = CreateDIBSection(hDC,
&biBitmapInfo,
DIB_PAL_COLORS,
(void**)&pui8ImageContent,
NULL,
0);
HBITMAP holdObj = (HBITMAP)SelectObject(hDC, hBmp1);
if (NULL == holdObj)
{
AfxMessageBox(L"Bitmap Selection failed");
}
CBitmap* aBMP = CBitmap::FromHandle(hBmp);
BITMAP* abmpDim = NULL;
aBMP->GetBitmap(abmpDim);
memset(pui8ImageContent, 0, m_iOverallSizeInBytes);
LOGFONT SLogFont = {0};
memset(&SLogFont, 0, sizeof(LOGFONT));
SLogFont.lfHeight = 50;
SLogFont.lfWidth = 50;
SLogFont.lfCharSet = GB2312_CHARSET /*HANGUL_CHARSET*//*DEFAULT_CHARSET*/;
SLogFont.lfEscapement = 2700;
SLogFont.lfOrientation = 2700;
SLogFont.lfItalic = FALSE;
SLogFont.lfUnderline = FALSE;
SLogFont.lfStrikeOut = FALSE;
SLogFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
SLogFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
SLogFont.lfQuality = DEFAULT_QUALITY;
SLogFont.lfPitchAndFamily = VARIABLE_PITCH|FF_ROMAN;
wcscpy(SLogFont.lfFaceName,_T("@Simsun"));
HFONT hChFont = CreateFontIndirect(&SLogFont);
if (NULL == hChFont)
{
AfxMessageBox(L"Font Creation failed");
}
CFont* pFont = pDC->GetCurrentFont();
HFONT hFont = (HFONT)SelectObject(hDC, hChFont);
if (NULL == hFont)
{
AfxMessageBox(L"Font selection failed");
}
BOOL aStringWtitten = ExtTextOut(
hDC, // Rendering canvas
SSize.cy + iVerStartBit + 50, // x-offset
100, // y-offset
ETO_OPAQUE,
NULL,
szString,
wcslen(szString),
NULL);
if (false == aStringWtitten)
{
AfxMessageBox(_T("Write text failed"));
}
BitBlt(pDisplayDC->GetSafeHdc(),50, 0, 500, 500, hDC, 0, 0, SRCCOPY);
}
|
|
|
|

|
Have i asked the question in a wrong forum
|
|
|
|

|
Nope, this is the correct forum; but your question might be a bit too advanced for most of us. I'd be looking for an alternative by now, like painting the text on a bitmap and rotate that.
Did you solve your problem? If yes, how?
|
|
|
|

|
I guess this is a bug, its not uncommon. Especially because the win32 (more maintained) sibling works well.
|
|
|
|

|
Hi,
I tried to port the fork API in Linux to Windows (Windows 7 and Windows 8) using the native API RtlCloneUserProcess as discussed in the following link.
http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/afdf1b68-1f3e-47f5-94cf-51e397afe073/
With the RtlCloneUserProcess function, child process is created, but didn’t get the console handle, stdin, stdout etc. The solution is to inform the CSR /win32 subsystem about the new process. But I could not able to do that. Please help me to re link the child process to the CSR.
|
|
|
|

|
akhilmv88 wrote: With the RtlCloneUserProcess function, child process is created, but didn’t get the console handle, stdin, stdout etc.
I see more risks; an app locking a file that gets forked, will be in trouble.
akhilmv88 wrote: The solution is to inform the CSR /win32 subsystem about the new process.
I did not see that "solution" in the thread you linked.
akhilmv88 wrote: But I could not able to do that.
Include the error-message, or at least the return-value.
|
|
|
|

|
In the link it is given that “For the console, you do need to re-establish a link to csrss, but the setup is only done in ntdll if the CsrPort handle is NULL. This isn't the case in the forked process which of course, has the parent processes handle value. Nowhere in ntdll sets it to back to NULL so there's no chance of getting that to work unless you d/l the ntdll symbols, find where the handle is, and NULL it out yourself.”
Also on further analysis on the CRS, it is understood that CSRSS is responsible for Win32 console handling. The link, http://translate.google.co.in/translate?hl=en&sl=ru&u=http://www.wasm.ru/forum/viewtopic.php%3Fid%3D42246&prev=/search%3Fq%3DCsrClientCallServer%26hl%3Den%26tbo%3Dd%26biw%3D991%26bih%3D598&sa=X&ei=e17FUNP7NMrtrQeA7IFo&ved=0CGAQ7gEwBg , gave some idea to manually notify the CSR about the new process, but I could not able to do that in windows 7.
The CsrClientCallServer function returns a negative value and the data buffer to the api CsrClientCallServer got corrupted after the call.
|
|
|
|

|
Not a word on that function in MSDN. CsrClientCallServer is an undocumented (internal) function, and it's fingerprint may vary without warning.
Sorry, can't help here.
|
|
|
|

|
How can an item be added to context menu that pops up when highlighting a part of text in any program and right clicking ? And a code should be associated with that which processes the piece of text highlighted. The item should be added to every programs context menu when text can be selected;ex Internet Explorer , Firefox , notepad, etc...
I have some general methods in my mind from my studies revolving around windows internals. But no specifics.
What is the best way to do it ? can this be done by writing code in kernel mode ? how ? is it necessary ? what are other methods which involve user mode programming ?
|
|
|
|

|
You cannot add items to every context menu on the system; not all of them are dynamic. You can add to Windows Explorer and (probably) IE by writing extensions or via other published interfaces. Try a Google search for samples and articles on the subjects.
One of these days I'm going to think of a really clever signature.
|
|
|
|

|
Richard MacCutchan wrote: You cannot add items to every context menu on the system
Even by coding in assembly level ?
Can a program be written that when it runs overrides the default belavior of the system ? When selecting and right clicking any piece of text , our custom context menu appears in place of the default ? I mean overriding this behavior on the system-wide level.No matter in IE or any other programs as long as a text selection is concerned.
|
|
|
|

|
devboycpp wrote: Even by coding in assembly level ? Why do you think that will make a difference?
devboycpp wrote: overrides the default belavior of the system ? Possibly by windows hooking but you would still need to check which program is active every time you trap a message, before you could decide what action to take. The problem is that context menus are not generated in a single place within the system so you cannot have a universal piece of code to intercept them all.
One of these days I'm going to think of a really clever signature.
|
|
|
|

|
Richard MacCutchan wrote: Why do you think that will make a difference?
I think you are familiar with windows debugging techniques using tools like WinDbg. By using them we can go deep in kernel and put breakpoints in kernel code or every where in memory. As all usermode programs' API interactions eventually goes in kernel and for similar functionalities like showing context menu similar kernel code is invoked. So by using techniques like modifying an API function parameter before it is passed to the API(I am just guessing) or alike, can we modify the system behavior.
I mean programs use a common API for similar functionality(like context menu), so by installing our code before the API is invoked maybe we can modify the behavior;Techniques like import address table modification.
Richard MacCutchan wrote: The problem is that context menus are not generated in a single place within the
system so you cannot have a universal piece of code to intercept them all.
But they are generated by using common APIs, aren't they ?
|
|
|
|

|
devboycpp wrote: we can go deep in kernel and put breakpoints in kernel code or every where in memory. I don't think so, kernel code is not accessible by user programs.
devboycpp wrote: But they are generated by using common APIs, aren't they ? Possibly, but I'm not sure it's that straightforward.
One of these days I'm going to think of a really clever signature.
|
|
|
|

|
Richard MacCutchan wrote: I don't think so, kernel code is not accessible by user programs.
I guess you are not familiar with WinDbg tool. It is a debugger which can run in kernel mode. And in kernel mode debugging ,breakpoints can be set everywhere including kernel code.
Richard MacCutchan wrote: Possibly, but I'm not sure it's that straightforward.
Sure it is not so.
Thanks for comment anyway.
|
|
|
|

|
devboycpp wrote: a debugger which can run in kernel mode. I have never used WinDbg, something else to add to my list of things to learn.
One of these days I'm going to think of a really clever signature.
|
|
|
|

|
Would you mind to say how old you are ? Just curiosity.
|
|
|
|

|
Old!
One of these days I'm going to think of a really clever signature.
|
|
|
|

|
Just wanted to know your age .
|
|
|
|

|
Why, is it relevant to anything?
One of these days I'm going to think of a really clever signature.
|
|
|
|

|
Richard MacCutchan wrote: Why, is it relevant to anything?
No just the reason is why people put their age in their profile. Just to let people know. I don't mean to relate it to anything.
|
|
|
|
 |