I've not used this myself, but let's step through and give an example:
HINTERNET hinternet = InternetConnect(...); //assume hinternet is valid
if (!FtpCreateDirectory(hinternet, "C:\\example")) {
std::cerr << "Error creating FTP directory. Code: " << GetLastError();
}
Step by step:
- First, we get a
HINTERNET
handle. How? Well, the docs say this about the parameter:
Handle returned by a previous call to InternetConnect using INTERNET_SERVICE_FTP.
That's why I called InternetConnect
in the example.
- Next, we look at the second parameter. Looking at the
Windows Data Types
article, you can see that it takes either a CONST WCHAR *
or CONST CHAR *
, depending on whether UNICODE
is defined. For simplicity, I acted as though it wasn't, though you can use the TEXT
macro to make a string literal wide or narrow depending on UNICODE
.
Pointer to a null-terminated string that contains the name of the directory to be created. This can be either a fully qualified path or a name relative to the current directory.
As we can see, it's just a path, so I passed in an example path. This is just an example, but keep in mind what the Remarks section says about this parameter.
- Now, we check the return value:
Returns TRUE if successful, or FALSE otherwise. To get a specific error message, call GetLastError. (more not shown)
Therefore, we wrap the call in an if statement to catch an error, which we can retrieve the code for using GetLastError
. It's important to use the error handling technique described in each function's article. A lot of them say that upon an error, you can use GetLastError
, but some don't support GetLastError
usage, and some support different types of error retrieving functions, so make sure to follow the guidelines for each function individually.
Other than that, the _In_
means that the parameter goes in and it's no use after. This is opposed to, among others, _Out_
, which means that you'd pass in allocated memory and the function would write to it, so you can use it after the function call with the value the function writes.