|
Sorry , don't function :
error C2664: 'base64_encode' : cannot convert parameter 1 from 'char *' to 'const unsigned char *'
modified on Saturday, May 8, 2010 6:16 AM
|
|
|
|
|
Unless the internal buffer of m_sLogin needed changed, why would you suggest using GetBuffer() ?
"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
|
|
|
|
|
|
Koma Wang wrote: the error code:
error C2664: 'base64_encode' : cannot convert parameter 1 from 'class CString' to 'const unsigned char *'
You could either use:
base64_encode((LPBYTE) (LPCTSTR) m_sLogin, m_sLogin.GetLength());
or
base64_encode((const LPBYTE) (LPCTSTR) m_sLogin, m_sLogin.GetLength());
"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
|
|
|
|
|
Have you tried casting the CString from LPCTSTR ), like this:
std::string encoded_login = base64_encode((const unsigned char*)(LPCTSTR)m_sLogin,m_sLogin.GetLength());
It's time for a new signature.
|
|
|
|
|
Great ! It's working ! Thank you all !
|
|
|
|
|
Hi all,
I created SDI based project in MFC.In View class(OnInitialUpdate()), i initialized serial port and created a worker thread which has to read data continuously and post data to a Framedialog.The Problem is ,only once the thread is posting message, not continuously.
My code is below.
UINT ClientThreadProc(LPVOID pParam)
{
CSerialCommView *pMyprocess = (CSerialCommView *)pParam;
CString mystr=pMyprocess->SerialPortContinuousRead();
LPTSTR lpMessage = new TCHAR[mystr.GetLength()];
_tcscpy( lpMessage , mystr);
::SendMessage(pMyprocess->GetSafeHwnd(),
WM_READ_DATA_AVAILABLE,0,(LPARAM)lpMessage);
return 0;
}
LRESULT CSerialCommView::OnDataAvailable(WPARAM wparam, LPARAM
lparam)
{
LPTSTR data= (LPTSTR)lparam;
CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd();
CEdit* DispBox=(CEdit*)pFrame->m_wndDlgBar.GetDlgItem(IDC_DISPLAY_BOX);
DispBox->SetWindowTextW(data);
return 0;
}
Thanks in advance.
|
|
|
|
|
From what you've posted it looks as if your program:
Enters new thread at ClientThreadProc .
Calls SerialPortContinuousRead which presumably completes and returns a string when it receives one.
Sends the string to the handler using SendMessage doesn't return until the handler completes (Consider PostMessage ).
ClientThreadProc then ends.
To read more than one message try a loop within ClientThreadProc or SerialPortContinuousRead and post (or Send) messages from there rather than returning the message from SerialPortContinuousRead and then exiting the threadproc.
modified on Saturday, May 8, 2010 8:24 AM
|
|
|
|
|
I have a problem setting up OpenGL in a C++ program using Win32. I have a main window that has buttons and checkboxes to control different parameters. After that I want to have two windows that will draw OpenGL code. The two child windows do not reside inside the main window, they are floating, WS_OVERLAPPEDWINDOW style(but I can make it any other style, it just has to work).
I am unsure how to properly create the two child windows and where to place the drawing code. I also do not know where to place the message loop for both of them.
Basically I press a button inside the main config window and my first window would show. If I press it again, then it should destry that window. Is there an example of something similar on the internet? Can someone help me? Thanks.
|
|
|
|
|
This thread has all the details
http://www.codeproject.com/Messages/3427974/Re-Second-Window-in-Win32.aspx
LRESULT CALLBACK childWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK parentWndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain ()
{
while (GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
LRESULT CALLBACK parentWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
...
}
return 0;
}
LRESULT CALLBACK childWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
...
}
return 0;
}
|
|
|
|
|
Thank you for your help, it is working well. However, I have a question. Where should I place the drawing code for the child window? I understand the procedure if I want to create another child window, i will call it child2. If I do create it, then where should I place the OpenGL code for it? I am not interested in drawing in the parent window, just inside the child window. Thank you again.
|
|
|
|
|
Gamedev has a great article on this topic.
http://www.gamedev.net/reference/articles/article540.asp[^]
Create a function say PaintOpenGL() , put all the OpenGL stuff in that function.
place PaintOpenGL() in the child window's message pump at case WM_PAINT .
case WM_PAINT:
PaintOpenGL();
break;
..
|
|
|
|
|
I want to use google translator aapi through an application I wrote the following code but CHttpFile::SendRequest() method always time out I could n't found what's my problem. Can any one help me?
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();
SendRequest() Method always timeout.
|
|
|
|
|
Hi,
m_code wrote: pHttpFile->AddRequestHeaders(L"content-length: 10\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
You have hard-coded a content-length of 10 bytes but I do not see where you write these bytes. The server is timing out because it is waiting for those bytes...
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks You were right.
That solved. But Again the following returns" http status 400" which means bad request any idea why this happens:
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->SendRequestEx(szText.GetLength());
pHttpFile->WriteString(szText);
pHttpFile->EndRequest();
DWORD dwRet;
pHttpFile->QueryInfoStatusCode(dwRet);
|
|
|
|
|
Hi,
Several issues...
1.) I am fairly certain that you should not be using HTTP_VERB_POST. Change that to CHttpConnection::HTTP_VERB_GET
The URL in your code does not seem to require a POST what you need to do is perform a GET request.
http://www.google.com/translate_a/t?client=t&sl=en&tl=tr&text=Hello[^]
If you click the URL above... what you have done is a GET request. We can pass all form data in the URL.
2.) You should remove the following line:
pHttpFile->AddRequestHeaders(L"Accept-Encoding: deflate\r\n", HTTP_ADDREQ_FLAG_ADD_IF_NEW);
This instructs the server to send you data compressed with the DEFLATE [^]algorithm.
3.) Since we are no longer doing a HTTP_VERB_POST then you do not need the Content-Length header.
4.) You will need to add this header:
<br />
"Content-Type: application/x-www-form-urlencoded"
There may be more errors but I do not see them for now. Fix these errors and tell me the result.
Best Wishes,
-David Delaune
|
|
|
|
|
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
|
|
|
|
|