|
Thank you for your reply.
I have did as what you said, but I only get the error message:
Unspecified error.
Here is my code:
_com_error err(hr);
auto d = err.WCode();
auto s = err.Description();
auto msg = err.ErrorMessage();
|
|
|
|
|
'Unspecified error' is the english error message for E_FAIL . There is no more information available.
|
|
|
|
|
You can try with GetLastError and see if you can get better description of the error . The number returned from the function you can check in msdn.
Good luck 
|
|
|
|
|
Hi,
I have developed an application which captures video stream using DirectShow. While capturing, video is displayed on the canvas area. This works fine for the first time. But when again clicking on Start capturing button, video is getting captured, it doesn't display in the canvas area. Don;t know whether actually the camera is capturing the video or not.
Anybody have any idea regarding this.?
Any help will be appreciated.!
Regards,
mbatra
|
|
|
|
|
You can debug to check if the code flow path is different from the first one in the second case.
If this doesn't help consider reinitialization of variables you are using before you display the video on the canvas.
You talk about Being HUMAN. I have it in my name
AnsHUMAN
|
|
|
|
|
Can you post some of your code?
I am using VFW API and OpenCV and debugging real time video can be a challenge.
What works for me is using temporary displays in step thru debug mode.
|
|
|
|
|
How to convert _uint64 into two _uint32 values and vice versa.
Regards,
Vishal
|
|
|
|
|
By shifting the high part and casting:
_uint64 ui64 = 1234;
_uint32 lo = (_uint32)ui64;
_uint32 hi = (_uint32)(ui64 >> 32);
ui64 = (_uint64)lo | ((_uint64)hi) << 32;
[EDIT:] Added code formatting.
|
|
|
|
|
does it take endianness into consideration, (Little/Big Endian)
Regards,
Vishal
|
|
|
|
|
Yes, because the endianess does not care for the used logical operations.
If you think of multiplication / division instead of the shift operations and of addition instead of the OR operation it should be clear. The operation values are just high or low parts where the internally used bit or byte order does not care. Casting is similar (extending with high zeroes upon up-casting and masking out the lower bits upon down-casting).
|
|
|
|
|
Thank you..
Regards,
Vishal
|
|
|
|
|
Here is another way to do it using the LARGE_INTEGER[^] union.
LARGE_INTEGER lint;
lint.QuadPart = 12345;
|
|
|
|
|
I too came across the union while using GetFileSize function.
does it produces same result in little endian and big endian systems.
as i want this for encryption section, where i had to convert 64bit unsigned integer to two 32 bit unsigned integer and vice versa,
So looking for results on little endian and big endian system result.
Regards,
Vishal
|
|
|
|
|
Yes, this will give you correct results irrespective of the endian-ness.
|
|
|
|
|
very very thank you sir.
Regards,
Vishal
|
|
|
|
|
I'm busy with my own http server implementation on an embedded platform. Technically the server is HTTP 1.0 compliant, and therefore it expects the the client to send the header "Connection: Keep-Alive" to keep the connection open.
The implementation looks like this. I removed the code that parses the HTTP header and performs the request, to keep the post as short as possible:
int Service_Request(int conn) {
struct ReqInfo reqinfo;
volatile int resource = 0;
int retval = 0;
Req_Result req_result = GOT_REQ;
InitReqInfo(&reqinfo);
while (req_result == GOT_REQ)
{
req_result = Get_Request(conn, &reqinfo);
if ( req_result == TIMEOUT_REQ)
{
retval = 0;
break;
}
else if (req_result == ERROR_REQ)
{
retval = -1;
break;
}
if (reqinfo.method == GET)
{
}
else if ((reqinfo.method == PUT) || (reqinfo.method == POST) )
{
}
else
{
reqinfo.status = 501;
Return_Error_Msg(conn, &reqinfo);
}
if(reqinfo.keep_alive == 0)
{
break;
}
reqinfo.keep_alive_max--;
if(reqinfo.keep_alive_max <= 0 )
{
break;
}
Writeline(conn,"\r\n",2);
FreeReqInfo(&reqinfo);
}
FreeReqInfo(&reqinfo);
return (retval);
}
The Get_Request function looks like this:
Req_Result Get_Request(int conn, struct ReqInfo * reqinfo) {
char buffer[MAX_REQ_LINE] = {0};
int rval;
fd_set fds;
struct timeval tv;
if(reqinfo->first_request == 1)
{
tv.tv_sec = 5;
tv.tv_usec = 0;
reqinfo->first_request = 0;
}
else
{
tv.tv_sec = reqinfo->keep_alive_timeout;
tv.tv_usec = 0;
}
do {
FD_ZERO(&fds);
FD_SET (conn, &fds);
rval = select(conn + 1, &fds, NULL, NULL, &tv);
if ( rval < 0 )
{
Diag_Msg("Error calling select() in get_request()");
return (ERROR_REQ);
}
else if ( rval == 0 ) {
return (TIMEOUT_REQ);
}
else {
memset(buffer,0,MAX_REQ_LINE - 1);
if(Readline(conn, buffer, MAX_REQ_LINE - 1) == -1)
{
return (ERROR_REQ);
}
if(reqinfo->clientRequest == NULL)
{
reqinfo->clientRequest = calloc(MAX_REQ_LINE - 1, sizeof(char));
strncpy(reqinfo->clientRequest,buffer,MAX_REQ_LINE - 1);
}
else
{
strncat(reqinfo->clientRequest,buffer,MAX_REQ_LINE - 1);
}
Trim(buffer);
if ( buffer[0] == '\0' )
break;
if ( Parse_HTTP_Header(buffer, reqinfo) )
break;
}
} while ( reqinfo->type != SIMPLE );
return (GOT_REQ);
}
To describe the workings of this server in English: The server receives the first request. It parses the headers, if it finds the "Connection: Keep-Alive" header, it sets a flag. The server proceeds to process this request. WHen it is done it checks the keep-alive flag. If it is cleared, the server closes the connection. If set the server performs a clean-up operation and the proceeds to wait for another request over the same connection. And so on.
I tested this with curl:
C:\curl>curl -v -H "Connection: Keep-Alive" --data-binary ( at )vid1.bin 10.84.67.129/s1p0:1/vid[1-2].bin
[1/2]: 10.84.67.129/s1p0:1/vid1.bin --> <stdout>
--_curl_--10.84.67.129/s1p0:1/vid1.bin
* About to connect() to 10.84.67.129 port 80 (#0)
* Trying 10.84.67.129...
* connected
* Connected to 10.84.67.129 (10.84.67.129) port 80 (#0)
> POST /s1p0:1/vid1.bin HTTP/1.1
> User-Agent: curl/7.28.1
> Host: 10.84.67.129
> Accept: **
> Connection: Keep-Alive
> Content-Length: 51200
> Content-Type: application/x-www-form-urlencoded
> Expect: 100-continue
>
* HTTP 1.0, assume close after body
< HTTP/1.0 100 Continue
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: DTSVU v0.1
< Content-Type: text/html
* HTTP/1.0 connection set to keep alive!
< Connection: Keep-Alive
< Keep-Alive: timeout=5, max=10
<
* Connection #0 to host 10.84.67.129 left intact
* Closing connection #
As you can see, curl says: Connection #0 seems to be dead! after the first request is completed. It then proceeds to close the connection and opens a new one. I'm sure I implemented the HTTP 1.0 keep-alive functionality correctly. SO my question is: what does curl expect over the connection after the first request is completed? Why does it decide the connection is dead?
PS the above code was adapted from http://www.paulgriffiths.net/program/c/webserv.php
|
|
|
|
|
This does not really have anything to do with C/C++; you may get a better response in the Web Development forum[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Sorry about about posting in the wrong forum. Could a moderator please move it?
I solved it myself. If the server replies with HTTP/1.1 and "Content-Length: 0", curl reuses the connection. My server reply lookes like this
HTTP/1.1 100 Continue
HTTP/1.1 200 OK
Server: DTSVU v0.1
Content-Type: text/html
Connection: Keep-Alive
Keep-Alive: timeout=1, max=95
Content-Length: 0
after the 5th reuse of the connection.
|
|
|
|
|
Hi
I'm having trouble trying to load a non-default .wab file (I know it's old hat but need to keep it going for my XP users). I'm running it on Vista and although I'm supplying a filename it keeps loading my Vista Contacts instead instead of the specific wab addresses.
It must be going wrong around here (mostly stock code from the msdn sample code):
// (pszFileName is const char *)
if(m_hinstWAB)
{
// if we loaded the dll, get the entry point
//
m_lpfnWABOpen = (LPWABOPEN) GetProcAddress(m_hinstWAB, "WABOpen");
if(m_lpfnWABOpen)
{
HRESULT hr = E_FAIL;
WAB_PARAM wp = {0};
wp.cbSize = sizeof(WAB_PARAM);
wp.szFileName = (LPTSTR) (LPCTSTR) pszFileName;
// if we choose not to pass in a WAB_PARAM object,
// the default WAB file will be opened up
//
if(m_lpfnWABOpen(&m_lpAdrBook,&m_lpWABObject,&wp,0)==S_OK)
m_bInitialized = TRUE;
}
As usual, any help much appreciated.
Greg
|
|
|
|
|
Why is this conversion needed:
Member 868926 wrote: wp.szFileName = (LPTSTR) (LPCTSTR) pszFileName; ?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Good point, well I'm now trying:
wp.szFileName = "C:\\Jim.wab";
as I know that wab exists there but it still isn't loading it.
G
|
|
|
|
|
Are you completely sure that is a correct WAB file and it is readable by the process (it has the required access rights and somesuch)?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Yes the wab is OK. If you doubleclick it Windows asks if you want to import the addresses.
Somehow the WabOpen bit just thinks I want the default Wab (although there isn't one in Vista) and isn't getting the filename. In the original code there was a 'GetNativePath()' call which isn't available - could it be to do with how I'm passing in the file location string?
G
|
|
|
|
|
As far as i remember the documentation says it will load the default if you pass NULL for the path, but you are not passing NULL but a seemingly correct path. Hmm...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
If i check the documentation (http://msdn.microsoft.com/en-us/library/ms629458%28v=vs.85%29.aspx[^]) for WAB_PARAM , the szFileName member is declared to be LPTSTR . This suggests that depending on your target options, it might be a unicode or an ansii/mbcs string which then suggests that there might be a unicode and an ansii/mbcs version of the function (as with a lot of API methods throughout windows). When you query the function's pointer...are you sure you are getting the correct version?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|