|
Hi,
thanks for taking time to help me
yes the HTTP_VERB_GET work correctly
But I need to use http post because, I need to traslate some text files with my application and http connection object
could not be such long, or it would take a lot of time if I use small buffer with loop,
I had a Qt Application that implement the above matter with POST and i works Correctly Here are the codes
QString url = QString("/translate_a/t?client=t&sl=en&tl=tr");
QHttpRequestHeader header = QHttpRequestHeader("POST", url, 1, 1);
header.setValue("Host", "www.google.com");
header.setValue("User-Agent", "Mozilla/5.0");
header.setValue("Accept-Encoding", "deflate");
header.setContentLength( text.length() );
header.setValue("Connection", "Close");
QByteArray ba("text=");
ba.append( text );
a_Http->setHost("www.google.com");
a_Http->request(header,ba);
a_done.exec(QEventLoop::AllEvents|QEventLoop::WaitForMoreEvents);
QString out = QString::fromUtf8( a_Http->readAll() );
I just want to implement this in MFC,
Regards
|
|
|
|
|
Can somebody help me to write code for converting a hexadecimal no. to octal no. using pointer in C.I am not getting how to accept a hexadecimal no. from user and how to convert it in to octal equivalent using C.Thanking you in advance.
|
|
|
|
|
Which part of this simple and solved a million times problem are you having trouble with?
The wonderful thing about the Darwin Awards is that everyone wins, especially the members of the audience.
|
|
|
|
|
I would suggest that you start by reading a book on number representation in computers. Then take a look here[^] for some useful links.
It's time for a new signature.
|
|
|
|
|
@Tim Sir I want to code it using pointers and by far there is no conversion directly from octal to hexadecimal.So it is not dat simple.....
@Richard I read books n found out that there is no direct conversion and if u have read it properly i want the code in C not in .NET as the libraries are totally different.
|
|
|
|
|
djsproject wrote: there is no direct conversion
read the octal into an integer and write it as an hexadecimal.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
I am looking a way to get PNP device Id for USB, CDRom, and hard disks, mapped network drives.
I know we can get through WMI calls.
My project requires not to use WMI and I am looking ways to get the PNP device id through windows native API calls.
I figured out that PNP device ids are listed in windows registry "HKLM\SYSTEM\CurrentControlSet\services\{service}\Enum.
Where {service} could be CDROM, disk, USBSTOR etc....
I have following questions on this.
1. How can I link back this "PNP device id" to the mounted volume letter?
2. Not finding a way to get "PNP device id" for network mapped drives?
3. Is there any IOCTL call to get the "PNP device id" for any volume or drive?
Thanks in advance
|
|
|
|
|
|
Thanks david for quick answer.
I was looking for PNP functions and references you pointed.
Definitely these API's looks promising to find PNP device Id.
However, how I can map my volume (drive letter) to its PNP device Id.
neither of functions actually refer for volume drive letter.
thanks-
Prashanth
|
|
|
|
|
|
Thanks david for quick reply.
I was able to enumerate all the device ID's with the above calls.
Definitely this is good progress for what I am looking.
However, none of the API's are actually refering the device id to the respective volume drives.
For example, if I could enumerate CDRom drives device id's, there is no way to know their volume drive letters.
In other way, volume information and corresponding device info are not related with these API's.
If you open "Device Manager" and select any disc drive, open properties and then volumes tab,
this will not list all the volumes by default.
However when you select "Populate", it is displaying all the volumes in the respective drive.
This is what exactly I am looking.
Either I should know volumes mounted on particular "Device ID" (or) get the device id for a given volume letter.
I dont know how "device manager" is populating drives with the device id?
Any thoughts or pointers?
Thanks-
Prashanth Jaligama
|
|
|
|
|
HI David,
thanks for all your pointers.
I am able to successfully enumerate volumes and their corresponding Device information using SetupDI functions.
1. SetupDI functions will list all devices for given class guid, such as disks, cdroms, volumes.
We can also query for its device number using IOCTL_STORAGE_GET_DEVICE_NUMBER.
2. Separately, all volumes can be retrieved using windows APIs, such as GetLogicalDrives, and then we can also query its device number using same IOCTL_STORAGE_DEVICE_NUMBER on drive letter (ex: \\\\?\\c .
Now I mapped device number in setupDI with the device number retrieved using volumes functions, which allows me to get both volume information and also its corresponding device information.
Of course, device number does not persist across boots, but my little software will keep refresh to map volume drives and its corresponding device info.
thanks-
Prashanth Jaligama
|
|
|
|
|
I read the Clipboard documentation on MSDN!
My application is listening in!
I'm running a timer to check if any text is stored in the Clipboard!
But it didn't detect any strings I copied from my browser!
However when I copied a md5 hash file, my timer went berserk informing it had found more than 1 clipboard data type.
OpenClipboard(Window);
if (!IsClipboardFormatAvailable(CF_TEXT))
Tu(L"ANSI Text!");
if (!IsClipboardFormatAvailable(CF_UNICODETEXT))
Tu(L"Unicode Text!");
if (!IsClipboardFormatAvailable(CF_OEMTEXT))
Tu(L"OEM");
CloseClipboard();
|
|
|
|
|
So what exactly is the question?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Im trying to program a URL catcher.
|
|
|
|
|
Fareed Rizkalla wrote: ...a URL catcher.
Who is throwing them?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
What do you mean who is throwing them?
I initialized my application to listen on the Clipboard.
Then I created a timer that would open the Clipboard to check if their is a URL it could use.
So my timer opens the Clipboard and checks if their is a certain data type stored in it.
However I was unable to detect the URLs I copied from my browser as CF_TEXT, CF_UNICODE and CF_OEMTEXT.
However when I copied a MD5 checksum file it triggered all of the above data types as available.
|
|
|
|
|
Fareed Rizkalla wrote: Then I created a timer that would open the Clipboard to check if their is a URL it could use.
So my timer opens the Clipboard and checks if their is a certain data type stored in it.
Why not call EnumClipboardFormats() to see what formats are currently available?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
You have ! in front of the IsClipboardFormatAvailable() calls, which looks wrong.
--Mike--
|
|
|
|
|
It can be send data to remote server from CString ?
Here is "original code" :
bool CSmtp::SendData()
{
int idx = 0,res,nLeft = strlen(SendBuf);
assert(SendBuf);
if(RecvBuf == NULL)
return false;
while(nLeft > 0)
{
if( res = send(hSocket,&SendBuf[idx],nLeft,0) == SOCKET_ERROR)
{
m_oError = CSMTP_WSA_SEND;
return false;
}
if(!res)
break;
nLeft -= res;
idx += res;
}
return true;
}
which I want to convert into :
BOOL CSmtp::SendData()
{
if(send(m_hSocket,m_sSendBuf,1024,0) == == SOCKET_ERROR)
{
m_nError = CSMTP_WSA_SEND;
return FALSE;
}
return TRUE;
}
m_sSendBuf is CString data member
|
|
|
|
|
mesajflaviu wrote: if(send(m_hSocket,m_sSendBuf,1024,0) == == SOCKET_ERROR)
I would use
if ( send( m_hSocket, m_sSendBuf, m_sSendBuf.GetLength(), 0) == SOCKET_ERROR)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You haven't mentioned what exactly you're problem is.
Is there a compiler error or is the data not being sent correctly?
There is a chance that you get a compiler error because the send function takes a const char* parameter and a CString in UNICODE builds contains a wchar_t array.
If this is a problem use CStringA explicitly.
CStringA sSendBuf = m_sSendBuf;
send(m_hSocket, sSendBuf, sSendBuf.GetLength(), 0);
|
|
|
|
|
Thank you all , seems to work !!! You make a happy man !
|
|
|
|
|
I use the PickIconDlg function that returns the path to module and index # of icon.
How can I get the resource id of that icon?
Thanks
|
|
|
|
|
I want to use google translator through an application I wrote the following code but it always time out what's my problem.
CString szTranReq(L"/translate_a/t?client=t&sl=en&tl=tr");
CString szText(L"text=Hello");
CString szServer(L"www.google.com");
DWORD inetPort = 80;
CInternetSession inetSession(::AfxGetAppName(), 1, PRE_CONFIG_INTERNET_ACCESS, NULL, NULL, NULL);
inetSession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, 1000 * 3);
inetSession.SetOption(INTERNET_OPTION_CONNECT_BACKOFF, 1000);
inetSession.SetOption(INTERNET_OPTION_CONNECT_RETRIES, 1);
CHttpConnection* pInetHttpConnection = inetSession.GetHttpConnection(szServer, inetPort, NULL, NULL);
CHttpFile* pHttpFile = pInetHttpConnection->OpenRequest(
CHttpConnection::HTTP_VERB_POST,
szTranReq, NULL, 1, NULL, NULL,
INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_DONT_CACHE);
pHttpFile->AddRequestHeaders(L"Host: www.google.com\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
pHttpFile->AddRequestHeaders(L"User-Agent: Mozilla/5.0\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
pHttpFile->AddRequestHeaders(L"Accept-Encoding: deflate\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
pHttpFile->AddRequestHeaders(L"content-length: 10\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
pHttpFile->AddRequestHeaders(L"Connection: Close\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
pHttpFile->SendRequest();
DWORD dwRet;
pHttpFile->QueryInfoStatusCode(dwRet);
SendRequest() Method always timeout.
|
|
|
|