|
You should also print out the contents of wfd.cFileName to see exactly which file or directory you are displaying attributes for.
I must get a clever new signature for 2011.
|
|
|
|
|
how can I put a literal "\" in
string without being recognize as an escape
character ?
the anwser is to double the "\" ...
s t r = " C : \ \ W i n d o w s " ;
i agree with you. But i want to do it programatically. I want to replace \ with ''\\''. Please help
Some Day I Will Prove MySelf :: GOLD
|
|
|
|
|
The '\\' notation is only needed for the compiler. It isn't needed in the runtime. (when you select a file from the open file dialog, the path is returned as "C:\New Folder"
If you want to replace them for other reasons, then use 4 '\'. i.e. to specify a SMB server, you would use CString strServer = "\\\\server_name\\folder"; .
To replace it you just need a replace function. If you are using something liks CString , it as a Replace() method.
CString strName = "\\hello";
strName.Replace("\\", "\\\\");
|
|
|
|
|
Thanx a lot.
Some Day I Will Prove MySelf :: GOLD
|
|
|
|
|
|
You already got answers the last time you posted, what's wrong with them ?
Please, read the posting guidelines at the top of this forum before posting the next time.
|
|
|
|
|
Hello guys!
I have to connect to WebDAV Server, example: http://webdav.pspace.co.kr
But I cannot find any code example for DavAddConnection Function.
And, in MSDN I found this:
"Use this function when you are connecting to a WebDAV server using the Secure Sockets Layer (SSL) protocol and therefore must specify a certificate. To connect to a WebDAV server without specifying a certificate, use a Windows networking function such as WNetAddConnection2 or WNetAddConnection3."
Does anyone know some examples of DavAddConnection?
Found some code examples for WNetAddConnection2 and tried to connect, but, unsuccessfully.
CString passW=_T("pwd123");
CString userN=_T("user1");
CString locname=_T("webdav.pspace.co.kr");
DWORD dwRetVal;
NETRESOURCE nr;
DWORD dwFlags;
memset(&nr, 0, sizeof (NETRESOURCE));
nr.dwType = RESOURCETYPE_ANY;
nr.lpLocalName = (LPTSTR)((LPCTSTR)locname);
nr.lpRemoteName = (LPTSTR)((LPCTSTR)locname);
nr.lpProvider = NULL;
dwFlags = CONNECT_UPDATE_PROFILE;
dwRetVal = WNetAddConnection2(&nr, passW, userN, FALSE);
if (dwRetVal == NO_ERROR)
AfxMessageBox(_T("Connection added to"));
else
AfxMessageBox(_T("Error"));
I'm getting "Error".
By the way, I'm I doing right trying to connect to WebDAV server via this technic?
Thank you.
modified on Thursday, January 20, 2011 8:30 PM
|
|
|
|
|
Use this to see what error you are getting. That may shed some light on what may be causing it
if (dwRetVal == NO_ERROR)
AfxMessageBox(_T("Connection added to"));
else {
TCHAR szError[32];
_stprintf(szError, _T("Error %u"), dwRetVal);
AfxMessageBox(szError);
}
|
|
|
|
|
Thanks for the reply.
I'm getting "Error 487".
|
|
|
|
|
MSDN[^] says
Error Name: ERROR_INVALID_ADDRESS
Error Code: 487 (0x1E7)
Error Text: Attempt to access invalid address.
|
|
|
|
|
Check out your last parameter in WNetAddConnection2(&nr, passW, userN, FALSE);
According to MSDN[^] 0 is not a legal value for the parameter dwFlags and FALSE is #define FALSE 0 .
Did you mean to pass in your variable dwFlags ? (in the sample on MSDN they do)
|
|
|
|
|
Hello.
I have tried a couple of thing to make the code work. But, still, I cannot connect to our WebDAV server "webdav.pspace.co.kr".
But, using the code shown below, I'm getting a positive answer: "Connection added to":
CString locname=_T("\\\\www.barracudaserver.com\\dav\\");
DWORD dwRetVal;
NETRESOURCE nr;
DWORD dwFlags;
memset(&nr, 0, sizeof (NETRESOURCE));
nr.dwScope=RESOURCE_GLOBALNET;
nr.dwType = RESOURCETYPE_ANY;
nr.lpLocalName = NULL;
nr.lpRemoteName = (LPTSTR)((LPCTSTR)locname);
nr.lpProvider = _T("");
dwFlags = CONNECT_UPDATE_PROFILE;
dwRetVal = WNetAddConnection2(&nr, _T(""), _T(""), dwFlags);
if (dwRetVal == NO_ERROR)
{
AfxMessageBox(_T("Connection added to"));
}
else
{
TCHAR szError[32];
_stprintf(szError, _T("Error %u"), dwRetVal);
AfxMessageBox(szError);
}
In the case of locname=_T("\\\\webdav.pspace.co.kr\\") the result is "Error 53:", which means "The network path you specified is not found."
May be something is wrong with the server or may be I'm using the wrong approach.
Any ideas?..
|
|
|
|
|
Running your code with locname=_T("\\\\webdav.pspace.co.kr\\") and running a packet sniffer I get the response
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Authorization Required</title>
</head><body>
<h1>Authorization Required</h1>
<p>This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
<hr>
<address>Apache Server at webdav.pspace.co.kr Port 80</address>
</body></html>
I'm sure you can figure out what the problem is from the response
|
|
|
|
|
Dear Andrew!
Thanks for your help!
I'm sorry for being pesky and dumb.
I can connect to the server using browser with username and password.
But, I'm not being able to do it using my app.
Still I get the same error: "The network path you specified is not found.".
|
|
|
|
|
I have never used WNetAddConnection2, and what I have been telling you is from reading MSDN and running your code on my computer so i dont know of any reasons that this might be hapening. Since i dont have an account on webdav.pspace.co.kr[^] the best i can offer is that you run Wireshark[^] and start the sniffer while you try to connect to the server to see what the server is sending back to you.
|
|
|
|
|
Hi,
you might want to check out this part
nr.lpLocalName = (LPTSTR)((LPCTSTR)locname);
based on MSDN: http://msdn.microsoft.com/en-us/library/aa385413(v=vs.85).aspx[^]
lpLocalName should be NULL in you case
"A pointer to a null-terminated string that specifies the name of a local device to redirect, such as "F:" or "LPT1". The string is treated in a case-insensitive manner."
but you use webdav.pspace.co.kr, which may cause the problem I think...
|
|
|
|
|
Hi,
I want to use a Active X contol in a win32 application.
How I can add that control to my project?
If you can Please explain me with a sample code.
Regards,
M.Mathivanan
|
|
|
|
|
Active X components are basically COM components.
So you can create an instance of it and then use the control in your application.
I am a HUMAN. I have that keyword in my name........
_AnsHUMAN_
|
|
|
|
|
That's a but simplistic. An ActiveX control is a COM object but writing code to correctly host it is far from trivial: in fact it's hard. The easiest way is to use MFC's or ATL's hosting code.
Steve
|
|
|
|
|
|
Hi,
Is there anyway to get the country name of system?
|
|
|
|
|
|
I tried it but I am getting "US" as my system time zone and Ip is of india.
On what basis it is giving "US" and how can I get correct country name?
|
|
|
|
|
john5632 wrote: On what basis it is giving "US" and how can I get correct country name?
Check the locale of your PC from the Control Panel, Region and Language link.
I must get a clever new signature for 2011.
|
|
|
|
|
Hi all,
i m working on SDI type splitter application.
i have split my application in one row and two column ,for first column im using CTreeView derived class and for second column i m using CFormView derived class.
in second column i m replace diffrent-2 formview according to need.
its working fine.but at certain point i need to chk which formview is currently visible in second column.
please tell me what function and api use for this.
thanks in advance.
|
|
|
|