|
Good link, thanks CPallini!
regards,
George
|
|
|
|
|
I am using VS2005.
When I want to build a project using Vista SDK libraries ( Media Foundation) I receive errors below :
1>c:\program files\microsoft sdks\windows\v6.0\include\propsys.h(896) : error C2061: syntax error : identifier '__RPC__out'
1>c:\program files\microsoft sdks\windows\v6.0\include\propsys.h(900) : error C2061: syntax error : identifier '__RPC__in'
1>c:\program files\microsoft sdks\windows\v6.0\include\propsys.h(905) : error C2061: syntax error : identifier '__RPC__in_opt'
1>c:\program files\microsoft sdks\windows\v6.0\include\propsys.h(1305) : error C2061: syntax error : identifier '__RPC__out'
1>c:\program files\microsoft sdks\windows\v6.0\include\propsys.h(1308) : error C2061: syntax error : identifier '__RPC__deref_out_opt'
I am getting some errors also for structuredquery.h.
In Tools->Options->vc++ Projects , my includes file directories order is :
$(VCInstallDir)PlatformSDK\include
$(VCInstallDir)include
C:\Program Files\Microsoft SDKs\Windows\v6.0\Include
$(VCInstallDir)atlmfc\include
$(FrameworkSDKDir)include
How can I resolve this issue ? Thanks
|
|
|
|
|
Hi,
Any ready solutions, or should I build this logic by myself ? I know how to change owner, but how to do it on child objects ?
( I mean the same action as windows security GUI checkbox "Replace owner on subcontainers and objects" does )
thanks
Vilius
|
|
|
|
|
hy,i am new to this and have a little problem.
i am tryng to simulate a keystroke in a game calld 9dragons,but he has a protection calld GameGuard that is blocking my program.i am using keybd_event to send the keystroks,but this GameGuard blocks them,sendinput() and send();i have noticed that if i you "on screen keyboard" from windows it works,i can send keystrokes with that program,can some1 tell me another way i can send the keystrokes to the game or how dose on screen keyboard works.the game is mayd in directX if it mathers...
here is my code :
<br />
#include <string.h><br />
#include <iostream><br />
#include <windows.h><br />
<br />
using namespace std;<br />
int main () {<br />
HWND window,hh,hw;<br />
int contor = 0;<br />
while (contor!=1) {<br />
hh = GetForegroundWindow(); <br />
hw = FindWindow("X3DKernel",NULL);<br />
if (hh=hw)<br />
contor = 1;<br />
} <br />
if (contor == 1) {<br />
for (int i=0;i<500;i++) {<br />
keybd_event(VkKeyScan('1'),0x02,0 , 0);<br />
keybd_event(VkKeyScan('1'),0x02, KEYEVENTF_KEYUP,0);<br />
Sleep(1500);<br />
keybd_event(VkKeyScan('5'),0x06,0 , 0);<br />
keybd_event(VkKeyScan('5'),0x06, KEYEVENTF_KEYUP,0);<br />
Sleep(3000);<br />
} <br />
system("pause");<br />
}<br />
} <br />
</windows.h></iostream></string.h>
the code works for programs like notepad
|
|
|
|
|
See if this works:
UINT __declspec(naked) WINAPI SafeSendInput(UINT nInputs, LPINPUT pInputs, int cbSize)
{
_asm {
mov eax, 11F6h
mov edx, 7FFE0300h
call dword ptr ds:[edx]
retn 0Ch
}
}
|
|
|
|
|
can you explain pls? i dont know assembly
|
|
|
|
|
Im (trying) to create a very, very simple TCP client and server which will connect and send a string of data that is 64 characters long. Im using Server Client Sockets[^] and Simple TCP Server[^] I have pretty much copy paste the code, and the actual 64 characters data transfer works fine. But now im moving on to making the client (which connectets to the listeing server) connect again maybe 100 ms later, to update the data. Notice that the cleint is re-doing all of the socks code, the whole WSAstartup, socket init etc. this part can work fine for a few hundred connections, but sometimes, at what seems random intervals the connecting just dies for a while, a few seconds later its back up and going. Im not getting any error, or return, its just like the socket initing freezes for a few seconds, then keeps going. I tried making the connection stay open, so it just revc's but i could not get it to work. (im very new to socks...)
Im guessing windows/socks doesnt like my program rapidly disconnecting and then creating a new connection all the time, because in my firewall/netstat it seems my program has loads of open connections to many other ports (and i only want it to use 23)
<br />
TCP thecomp:3172 localhost:telnet TIME_WAIT<br />
TCP thecomp:3174 localhost:telnet TIME_WAIT<br />
TCP thecomp:3175 localhost:telnet TIME_WAIT<br />
TCP thecomp:3176 localhost:telnet TIME_WAIT<br />
TCP thecomp:3177 localhost:telnet TIME_WAIT<br />
TCP thecomp:3178 localhost:telnet TIME_WAIT<br />
TCP thecomp:3179 localhost:telnet TIME_WAIT<br />
TCP thecomp:3182 localhost:telnet TIME_WAIT<br />
TCP thecomp:3183 localhost:telnet TIME_WAIT<br />
TCP thecomp:3185 localhost:telnet TIME_WAIT<br />
TCP thecomp:3186 localhost:telnet TIME_WAIT<br />
TCP thecomp:3187 localhost:telnet TIME_WAIT<br />
TCP thecomp:3190 localhost:telnet TIME_WAIT<br />
TCP thecomp:3191 localhost:telnet TIME_WAIT<br />
TCP thecomp:3193 localhost:telnet CLOSE_WAIT<br />
TCP thecomp:3194 localhost:telnet TIME_WAIT<br />
TCP thecomp:3196 localhost:telnet TIME_WAIT<br />
TCP thecomp:3197 localhost:telnet CLOSE_WAIT<br />
TCP thecomp:3199 localhost:telnet TIME_WAIT<br />
TCP thecomp:3200 localhost:telnet TIME_WAIT<br />
TCP thecomp:3201 localhost:telnet TIME_WAIT<br />
TCP thecomp:3203 localhost:telnet TIME_WAIT<br />
TCP thecomp:3204 localhost:telnet TIME_WAIT<br />
TCP thecomp:3205 localhost:telnet TIME_WAIT<br />
TCP thecomp:3207 localhost:telnet TIME_WAIT<br />
Any ideas on whats wrong?
I just want a very simple way to transfer approx 64 characters over a LAN, very often. Lowtech is nice, because in the future it is going to be over a WiFi, in which a bad connection can occur, that is why i would like to keep my code to init, connect, disconnect every 100ms. (in which a constant connection may take more time to restart)
If anyone has any idea to other methods of simple data transfer (maybe UDP?) im open to all ideas...
Maybe there is some nice code i can #include in my project which will do the connecting for me?
Thanks!
PS. Visual Studio 6.0, MFC Dialog Application
//Johannes
|
|
|
|
|
Hi Johannes,
the information you see with netstat looks okay (a normal behaviour of TCP). Can you describe your error behaviour a bit more or post the client code? Basically it is possible to open a connection every 100ms, but it could be much more effective if you stay connected and only reconnect if the connection was interrupted (depends on what you want to do).
/M
|
|
|
|
|
Thanks for the reply. I was recently suggested to add shutdown(socket, SD_BOTH); this made it more reliable, but still not 100%. At the moment it seems that connect function just freezes for a few seconds and then returns that it failed (to connect to the server) The connection is however fine, as both before and after it kept going. This seems to happend at random intervals. (between ~100 connections to ~2500)
Right now though, im probably re connecting every 50-100ms (cant remember)...
Note that what i pasted from netstat is just a little of it, there were so many i cant even copy them all as they go beyong max content of a normal cmd window...
I would (if possible) like to stay with a non-constant connection, as this is easier for me (if i get it to work) + faster on a unreliable connection.
Thanks
//Johannes
|
|
|
|
|
Hi again! Without the error code it is hard to figure out what is going wrong and I can only guess. Maybe your are using hostnames (rather than IPs) and the DNS resolution blocks when connecting or you didn't close sockets properly (in client or server code) and reached an upper limit per process. In any case, your application will only work inside the LAN very well, on the internet you will probably encounter longer round trips than 50-100ms and the TCP handshake alone probably takes more time than sending your payload data. Again I am only guessing... it would be helpful to see code, error codes or your application requirements.
Hope it helps.
|
|
|
|
|
Hey,
connect(theSocket,(LPSOCKADDR)&serverInfo, sizeof(serverInfo)); is returning -1 ( SOCKET_ERROR ). It seems to happend just randomy. This time it occured after ~7000 connections. My program does resolve a DNS name, which is placed inside the hosts file (like localhost), that should work instantly...
It just errord again, once more now. There is a very long time between between connect attemp, and when it returns -1 , maybe like ~15 seconds...
Yea, my program is only gonna run on a direct LAN, or maybe between a few switches/router.
I want a simple and reliable way to send a 64char string, if i use TCP/UDP/ICMP/Multicast doesnt really matter, and my server side doesnt need to know if the data came to the client or not...
Thanks!
//Johannes
|
|
|
|
|
Maybe your are running out of socket objects. Again I am only guessing... it would be helpful to see source code and detailed error codes (WSAGetLastError).
|
|
|
|
|
If i call WSAGetLastError() after the connect function fails it returns a 0. I dont know what that suggests though... What other detailed error codes can i find in my program?
How would I convert the code i linked to above into a open connection type?
Or maybe there is some example code of open TCP connection on codeproject?
//Johannes
|
|
|
|
|
Johpoke wrote: If i call WSAGetLastError() after the connect function fails it returns a 0. I dont know what that suggests though... What other detailed error codes can i find in my program?
Morning Johannes, maybe the error occurs earlier in your source code, check function return codes.
Johpoke wrote: How would I convert the code i linked to above into a open connection type?
Which code, sorry I don't understand what you mean.
/M
|
|
|
|
|
Hey, just a quick question about your requirements: Do you want to send 64 bytes from client to server without a response in regular intervalls... or the other way around where the server sends data to every incoming client?
|
|
|
|
|
The server (which binds to port 23) is listening to incoming clients, and as soon as one connects, it sends the 64 characters, and then disconects the client, waiting for a new one.
So the second way in you message.
But yea, the server doesnt need to know anything really, just send the string upon new client. (the server doesnt have any idea when i cleint is coming either (ie in what interval)
When i was testing it a few mins ago, the interval was Sleep(50);
Thanks!
//Johannes
|
|
|
|
|
Hej, with this requirements I would use a design like this:
- server delivers data when a client connects or sends a (zero) byte
- server closes connection only if there's no activity for 3 seconds or network/send error
- server closes connection after a persistent connection stayed 60 seconds
- server has an upper limit of x incoming sockets (more will be ignored)
- clients stay connected and may request data repeatedly
- clients close connection in case of network/receive/send error
- clients close connection if the received data was not according to protocol
- clients automatically reconnect only if they have been sucessfully connected and identified a server in last attempt
- clients could do multiple reconnect attempts, but with a delay (e.g. 60 seconds) and an upper limit of x reconnect attempts
This should give you a fairly efficient use of TCP and clients do not flood the LAN by error. Since you are using the telnet port on your server you could also use newline as a delimiter, which allows you do test with a telnet client.
|
|
|
|
|
Hello,
i have problems connection my webcam. I usw the video for windows (vfw.h).
Sometimesit works, i can see the live view and sometimes it doesnt work.
I have a main dialog and a setup dialog. when i push "setup" my setup dialog appears.
There, the use can choose the driver. I get the drivers by
<br />
for(int i = 0; i < 9; i++)<br />
{<br />
if(capGetDriverDescription(i,sName.GetBuffer(),sName.GetAllocLength(),<br />
sVersion.GetBuffe(),sVersion.GetAllocLength()))<br />
{ <br />
m_Drivers.Add(sName); <br />
}<br />
}<br />
in my main dialog there is a picture control element.
with GetClientRect i get the rect of this control and
fix it with ScreenToClient(&rect);
After that the InitCamera function is called.
<br />
void CUSBCamera::InitCamera(HWND HParent, int iDriverID, DWORD dwWidth, DWORD dwHeight, CRect rect)<br />
{<br />
m_hwndCap = capCreateCaptureWindow("USB-Camera",WS_CHILD | WS_VISIBLE,rect.TopLeft <br />
().x,rect.TopLeft().y,rect.Width(),rect.Height(),m_ParentWindowHandle,999);<br />
<br />
m_ParentWindowHandle = HParent; <br />
m_iDriverID = iDriverID;<br />
m_dwWidth = dwWidth;<br />
m_dwHeight = dwHeight;<br />
m_Rect = rect;<br />
<br />
capSetCallbackOnError(m_hwndCap, NULL);<br />
capSetCallbackOnCapControl(m_hwndCap,NULL);<br />
capSetCallbackOnStatus(m_hwndCap, NULL); <br />
capSetCallbackOnFrame(m_hwndCap, NULL); <br />
capSetCallbackOnVideoStream(m_hwndCap, NULL);<br />
capSetCallbackOnCapControl(m_hwndCap, NULL); <br />
capSetCallbackOnWaveStream(m_hwndCap, NULL);<br />
capSetCallbackOnYield(m_hwndCap, NULL);<br />
}<br />
Finished that, the connect function is called
<br />
BOOL CUSBCamera::Connect(LPFRAME_CALLBACK_PROC lpFrameCallback, LPVOID userData)<br />
{ <br />
if(capDriverConnect(m_hwndCap,m_iDriverID) && m_iDriverID >= 0)<br />
{<br />
capSetCallbackOnFrame(m_hwndCap,lpFrameCallback); <br />
capSetUserData(m_hwndCap,userData);<br />
<br />
DWORD dwSize; <br />
dwSize = capGetVideoFormatSize(m_hwndCap);<br />
m_lpbi = (LPBITMAPINFO)malloc(sizeof(BITMAPINFO)); <br />
<br />
<br />
capGetVideoFormat(m_hwndCap, m_lpbi, dwSize); <br />
m_lpbi->bmiHeader.biWidth = m_dwWidth;<br />
m_lpbi->bmiHeader.biHeight = m_dwHeight;<br />
<br />
capSetVideoFormat(m_hwndCap,m_lpbi,dwSize); <br />
<br />
capDriverDisconnect(m_hwndCap);
capDriverConnect(m_hwndCap,m_iDriverID);
<br />
capPreviewRate(m_hwndCap,100);<br />
capPreview(m_hwndCap,TRUE);<br />
<br />
<br />
free(m_lpbi);<br />
}<br />
else <br />
{<br />
::MessageBox(NULL,_T("Es ist ein Fehler aufgetreten"),_T("Fehler"),MB_OK);<br />
::DestroyWindow(m_hwndCap);<br />
return FALSE;<br />
}<br />
return TRUE;<br />
}<br />
My problem is, when i press update in my setup dialog i can choose just one driver.
Its the Windows WDM Capture (Win32).
Then i choose this driver press the apply button and i return back to the main dialog.
Well sometimes i see a picture from my webcam and sometimes its just black. i dont see anything.
Is there a certain order to initialize the camera ? And why do I have only just one driver in my list ? My graphicscard has a video in/out interface.
This makro capDlgVideoSource doestn work. With other applications i can connect to my webcam.
But with my try it's just a matter of luck getting access to it or not.
Well, one or two times it worked and i got this dialog. But choosing my webcam from the list
didnt change anything. Still had this black window i've created with capCreateCaptureWindow
If possible i want to avoid using the capDlgVideoSource dialog.
Please help me.
|
|
|
|
|
Hello again
i found out something interesting (well, for me it is).
I started a new simple project using th vfw interface.
But this time i also used capDlgVideoSource.
This time i could choose between my webcam and my video in from graphicscard.
And it worked. I got the view from my webcam. The interesting thing is, if i
choose my ATI video in from the capDlgVideoSource Dialog, close this program
and choose a driver in the actually program i dont see anything. Everthing is black.
When i start the programm where i use capDlgVideoSource and choose my webcam, close the program
and then choose the driver from my actually program it works.
Is there anyway to choose the source without using this capDlgVideoSource ?
It seems just selecting the driver (Windows WDM Capture) isnt enough.
greetings
|
|
|
|
|
I'm not sure how this is going to work...
for(int i = 0; i < 9; i++)<br />
{<br />
if(capGetDriverDescription(i,sName.GetBuffer(),sName.GetAllocLength(),<br />
sVersion.GetBuffe(),sVersion.GetAllocLength()))<br />
{ <br />
m_Drivers.Add(sName); <br />
}<br />
}
How large are your string buffers? Which gets called first - GetAllocLength() or GetBuffer()?
If you must use CString like this, I would recommend calling GetBuffer() first with an appropriate length.
You also must release the buffer before using it...
for(int i = 0; i < 9; i++)<br />
{<br />
LPTSTR pNameStrBuff =
sName.GetBuffer(256);<br /> LPTSTR pVersionStrBuff =
sVersion.GetBuffer(256);<br />
<br /> BOOL fRet = capGetDriverDescription(i, pNameStrBuff , 256, pVersionStrBuff
,256);<br />
<br />
sName.ReleaseBuffer();<br />
sVersion.ReleaseBuffer();
if (fRet)<br />
{ <br />
m_Drivers.Add(sName); <br />
}<br />
}
As far as getting the video to work - debug it. Check the return values from those calls.
Where is it failing?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello thanks for your answer.
I dotn have problems getting the drivers. This always works.
And yes, i also use sName.GetBufferSetLength( ).
I found the problem but dont know how to solve it.
As i told in my first reply i said that i wrote another small dialog for testing.
<br />
m_sLiveview.GetWindowRect(&m_Rect);<br />
ScreenToClient(&m_Rect);<br />
m_hwndCap = capCreateCaptureWindow(_T("USB"),WS_CHILD|WS_VISIBLE,m_Rect.TopLeft().x,m_Rect.TopLeft().y,m_Rect.Width(),m_Rect.Height(),this->GetSafeHwnd(),999);<br />
<br />
CString szDeviceName; szDeviceName.GetBufferSetLength(100);<br />
CString szDeviceVersion; szDeviceVersion.GetBufferSetLength(100);<br />
CAtlArray<cstring> List;<br />
<br />
for (int wIndex = 0; wIndex < 10; wIndex++) <br />
{<br />
if (capGetDriverDescription (wIndex, szDeviceName.GetBuffer(), szDeviceName.GetAllocLength(), szDeviceVersion.GetBuffer(),szDeviceVersion.GetAllocLength()))<br />
{<br />
List.Add(szDeviceName);<br />
}<br />
} <br />
<br />
capDriverConnect(m_hwndCap,List.GetCount()-1);<br />
CAPDRIVERCAPS caps;<br />
capDriverGetCaps(m_hwndCap,&caps,sizeof(CAPDRIVERCAPS));<br />
<br />
CString sMCIName;<br />
if (caps.fHasDlgVideoSource)<br />
{<br />
capDlgVideoSource(m_hwndCap); <br />
}<br />
<br />
capCaptureAbort(m_hwndCap);<br />
capSetCallbackOnError(m_hwndCap,NULL);<br />
capSetCallbackOnCapControl(m_hwndCap,NULL);<br />
capSetCallbackOnStatus(m_hwndCap,NULL);<br />
capSetCallbackOnFrame(m_hwndCap,FrameCallbackProc);<br />
capSetCallbackOnVideoStream(m_hwndCap, NULL);<br />
capSetUserData(m_hwndCap,NULL); <br />
<br />
capPreviewRate(m_hwndCap,150);<br />
capPreview(m_hwndCap,TRUE);<br />
</cstring> ;
with this settings it works because i call the capDlgVideoSource makro. There I can choose between
my graphicscard input and my webcam. So i think i need a way to get the device names instead
of the driver name. Althouh i have to input device installed (graphicscard video input and webcam) i can only choose one Windows WDM Capture Driver.
I also checked out the capGetMCIDeviceName but this only gets the previously set MCI device name.
Do you understand my problem ?
greetings
|
|
|
|
|
Member 3509166 wrote: So i think i need a way to get the device names instead
of the driver name
AFAIK there's no way from VFW. From VFW's point of view, there's just one driver - the
WDM driver wrapping (for VFW) the devices that don't have VFW-specific drivers (very few devices provide
VFW drivers anymore - they're pretty much obsolete).
I stopped using VFW long ago, so I never looked into it, but there may be a way to manipulate
the driver but it would be through WDM, not VFW.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello Mark, thanks for your reply.
I've just read this at another forum. someone had the same problem as me.
this is a part from public paper from 1997
"An example of incomplete API functionality can be found in the video capture API. Although it is possible to set the video source using a dialog box displayed to the user by calling the capDlgVideoSource function, doing the same from within an application without user mediation is, as far as we know, impossible. "
if this is true, it has never been fixed.
My webcam works when i use the capDlgVideoSource dialog.
But i want it without this.
At this forum someone wrote that the wdm handles more devices. so for me that means i can connect to the driver but if i have more than one device theres no other way getting acces to my webcam using this cap dialog.
the cap functions seems really easy to handle for me
greetings,
Robert
|
|
|
|
|
I don't know what to tell you.
Support for VFW was dropped many years ago. It's still there to support
legacy applications and that's it.
Probably your only choices are:
1) let the user select the device from the diaolg. I've never seen a driver that didn't persist these
settings.
2) Use a more modern video acquisition method.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi.
Just curious if anyone knows an easy way to change the height of a CStatusBar?
Thanks in advance.
Stan the Man
|
|
|
|
|