You are on page 1of 16

NetDrive2 SDK Reference

Bdrive Inc,
Copyright Bdrive inc, All Rights Reserved
1

version date e-mail
0.1 2014-4-10 jyyoon@bdrive.com
0.2 2014-5-9 jyyoon@bdrive.com
0.3 2014-6-14 jyyoon@bdrive.com
0.4 2014-7-14 jyyoon@bdrive.com


2

Contents
1 Overview ................................................................................................................................................................................ 3
2 Installation............................................................................................................................................................................. 4
2.1 Installation ............................................................................................................................................................... 4
2.2 Uninstallation ......................................................................................................................................................... 4
2.3 Verification of installation ................................................................................................................................. 4
2.4 To include header file and link library file................................................................................................ 5
3 API References .................................................................................................................................................................... 6
3.1 ND2_INIT .................................................................................................................................................................. 6
3.2 ND2_CONNECT ..................................................................................................................................................... 7
3.3 ND2_CONNECT_EX .............................................................................................................................................. 9
3.4 ND2_DISCONNECT ........................................................................................................................................... 10
3.5 ND2_DISCONNECT_ALL .................................................................................................................................. 11
3.6 ND2_SETSIZE ....................................................................................................................................................... 11
3.7 ND2_GET_CLOUDUSERNAME ...................................................................................................................... 12
3.8 ND2_SET_MOVE_FOLDER............................................................................................................................... 12
3.9 ND2_GET_CREDENTIAL ................................................................................................................................... 13
3.10 ND2_REFRESH_CLOUDUSAGE ..................................................................................................................... 13
3.11 ND2_SET_CALLBACK ........................................................................................................................................ 14




3

1 Overview
This document describes the about NetDrive 2.0 SDK


Support OS
Microsoft Windows 8
Microsoft Windows 8.1
Microsoft Windows 7
Microsoft Windows Vista
Microsoft Windows XP
Microsoft Windows Server 2003/2008/2012


4

2 Installation
2.1 Installation
To install NetDrive2 SDK, execute following command.
NetDrive2-SDKsetup.exe /NAME=$ND2_SDK_NAME /INSTDIR=$ND2_SDK_INSTDIR
$ND2_SDK_NAME must be a unique your string. ex) NetDrive2_SDK_APP
$ND2_SDK_INSTDIR is a path to install ex) C:\Program Files\ND2_App
Following command is an example.
NetDrive2-SDKsetup.exe /NAME=ND2_EX_APP /INSTDIR=C:\Program Files\ND2_EX_APP


2.2 Uninstallation
To uninstall NetDrive2 SDK, execute following command, $PATH is NetDrive2 SDK path.
$PATH\Uninstall.exe


2.3 Verification of installation
To verify installation, execute following command. $PATH is NetDrive2 SDK path
$PATH\dokanctl.exe /v

Below is the result of above command.
driver $PATH\dokan.sys
mounter path $PATH\mounter.exe
dokanctl : Jan 8 2014 07:08:40
Dokan version : 600
Dokan driver version : 0x190

5

2.4 To include header file and link library file
The header file and library file is in NetDrive2 SDK installed path.
Header nd2api.hh
library nd2api.lib


6

3 API References
Function Description
ND2_INIT Initiates NetDrive2 SDK with serial key
ND2_CONNECT Perform mounting a drive
ND2_CONNECT_EX Perform mounting with more parameters
ND2_DISCONNET Perform unmounting a mounted drive
ND2_DISCONNECT_ALL Perform unmounting all the mounted drives
ND2_SETSIZE Updates a total and free size values
ND2_GET_CLOUDUSERNAME Get user name of cloud storage service
Only for Google Drive, OneDrive
ND2_SET_MOVE_FOLDER Enable or disable to rename,move,delete
folder
Only for Amazon S3, Openstack Swift
ND2_GET_CREDENTIAL Get credential information. only for Google
Drive and OneDrive
ND2_REFRESH_CLOUDUSAGE Refresh free and used space of the mounted
drive. Only for Google Drive and OneDrive

3.1 ND2_INIT
BOOL ND2_INIT( LPCSTR lpSerial )

The ND2_INIT function initiates use of the NetDrive2 API by a process. It must be the
first function called by an application or DLL

Parameters
lpSerial : a given serial of NetDrive2 SDK

Return Value
If successful, it returns TRUE. Otherwise it returns FALSE.
Remarks
7

When ND2_INIT is called by an application or Dll, two nd2mounter.exe are
executed.


3.2 ND2_CONNECT
INT32 ND2_CONNECT(LPCSTR type, LPCSTR url, LPCSTR user, LPCSTR pwd, LPCSTR
drive , LPCSTR label )

The ND2_CONNECT function performs mounting a site to a letter.

Parameters
type : The null terminated string to mount type. Type must be one of supported
types. Supported types are below.
type Description
dav WebDAV connection
ftp ftp connection
sftp SFTP connection
s3 Amazon S3 connection
gdrive Google Drive connection
skydrive OneDrive(SkyDrive) connection

url : A url to connect. It must be a full formatted url including scheme, host,
path, port
Type scheme Description
dav http A general HTTP
https A HTTP over SSL/TLS
ftp ftp A general FTP
ftps A FTP over SSL/TLS
sftp sftp ftp over SSH

8

Ex) https://192.168.0.1:8080/path
Ex) ftps://192.168.0.2:21/path
user : A user account to connect
pwd : A password of user to connect
drive : A drive letter to be mounted.
Label : A label of drive letter to be shown
Return Value
value Description
0 Success
-100 Not initialized
-1 Drive error
-2 Drive letter error
-3 Drive install error
-4 Drive start error
-5 Mount error
10 Permission denied
11 Connection error
12 Path is not found.

Remarks
The url to connect must be a full formatted including scheme, host, port and path
If both user and password are NULL, it tries to connect anonymous
Example Code

ND2_CONNECT(dav, https://webdav.host.com:8080/data, useraccount,
password, Z , DAV )

9

3.3 ND2_CONNECT_EX
INT32 ND2_CONNECT_EX(LPCSTR type, LPCSTR url, LPCSTR user, LPCSTR pwd,
LPCSTR drive , LPCSTR label , LPCSTR key_file, LPCSTR user_agent, UINT32 option ,
PROXY_INFO *pProxyInfo )
The ND2_CONNECT_EX is similar to ND2_CONNECT. The ND2_CONNECT_EX is added
detailed parameters.

Parameters
key_file : If type is sftp, this pamameter is a private key file path on sftp
connection. if type is gdrive or skydrive, this parameter is a string of credential
getting by ND2_GET_CREDENTIAL function. Otherwise this parameter is ignored.
user_agent : A NULL terminated string to be User-agent value of HTTP header.
This parameter is valid if type is dav, otherwise ignored. Maximum length of
user_agent is 512.
option : A combination value of following.
defined value Description
NETWORK_DRIVE 0x00000000 Mount as a local drive
LOCAL_DRIVE 0x00000001 Moust as a network drive
SFTP_HOME 0x00000000 Mount point is a home
directory of user. This is valid if
type is sftp, otherwise ignored
SFTP_ROOT 0x00000002 Mount point is a root directory
of system. This is valid if type is
sftp, otherwise ignored.
UNMOUNT_KILLED 0x00000000 Unmount virtual drive when the
mounting process is killed
DONT_UNMOUNT_KILLED 0x00000004 Dont unmount virtual drive
even if the mounting process is
killed
HTTP_COMPRESS_GZIP 0x00000008 If type is dav, Accept-
encoding: gzip is added to
http request header.
FTP_PASSIVE 0x00000000 Use passive mode ftp transfer
10

FTP_ACTIVE 0x00000010 Use active mode ftp transfer
pProxyInfo : Proxy Information. A pointer of PROXY_INFO structure. It contains
proxy host, port, user account and password.

Return Value
Same with ND2_CONNECT

Remarks
Same with ND2_CONNECT

Example Code

ND2_CONNECT_EX(dav, https://webdav.host.com:8080/data, useraccount,
password, Z , DAV, NULL, netdrive2 sdk webdav client, 0x00 )

3.4 ND2_DISCONNECT
INT32 ND2_DISCONNECT( LPCSTR drive )

The ND2_DISCONNECT function performs unmounting a mounted drive

Parameters
drive : A NULL terminated string containing drive letter

Return Value
If successful, the ND2_DISCONENCT returns 0. otherwise it returns -1.

11


3.5 ND2_DISCONNECT_ALL
BOOL ND2_DISCONNECT_ALL()

The ND2_DISCONNECT_ALL function perform unmounting all the mounted drives.

Return Value
If successful, the ND2_DISCONNECT_ALL returns 1, otherwise it returns 0.


3.6 ND2_SETSIZE
INT32 ND2_SETSIZE( LPCSTR drive, __int64 total, __int64 free )

The ND2_SETSIZE function updates total and free size values of drive

Parameters
drive : a drive letter to be set size
total : total bytes size of drive
free : free bytes size of drive

Return Value
If successful, the ND2_SETSIZE returns 0, otherwise -1.


12

3.7 ND2_GET_CLOUDUSERNAME
BOOL ND2_GET_CLOUDUSERNAME( char *pDrive, wchar_t **pName)

Get user name of cloud service.
Parameters
pDrive : a mounted drive letter
pName (out) : a buffer of user name to be gotten

Return Value
If successful, the ND2_GET_CLOUDUSERNAME returns TRUE, otherwise FALSE.
Remarks
This function is valid only for gdrive and skydrive

3.8 ND2_SET_MOVE_FOLDER
void ND2_SET_MOVE_FOLDER( char *pDrive, __int32 flag )

The ND2_SET_MOVE_FOLDER function makes enable or disable to rename,move and
delete folder of a mounted drive.

Parameters
pDrive : a mounted drive letter to make enable or disable to rename, move and
delete folder
flag : 1 make enable to rename, move and delete folder. 0 make disable.

Remarks
13

This function is valid only for s3 and swift drive type.
A time out could be occurred when a folder is renamed or moved or deleted because
of features of s3 and swift.


3.9 ND2_GET_CREDENTIAL
BOOL ND2_GET_CREDENTIAL( char *pDrive, char **cred )

The ND2_GET_CREDENTIAL function gets the credential information of Google Drive
connection or OneDrive connection. This function is valid only for gdrive and skydrive
Parameters
pDrive : a mounted drive letter to get credential information
cred: output buffer to get credential information

Return Value
If successful, the ND2_GET_CREDENTIAL returns TRUE, otherwise FALSE.
Remarks
This function is valid only for gdrive and skydrive.

3.10 ND2_REFRESH_CLOUDUSAGE
void ND2_REFRESH_CLOUDUSAGE( char *pDrive )

The ND2_REFRESH_CLOUDUSAGE function refresh the free and used space of a mounted
drive.

14

Parameters
pDrive : a mounted drive letter to refresh a mounted drive

Remarks
This function is valid only for gdrive and skydrive.

3.11 ND2_SET_CALLBACK
BOOL ND2_SET_CALLBACK( ND2_CALLBACK_MSG pCallback )
The ND2_SET_CALLBACK function set a callback to function receive message from file
system

Parameters
pCallback : a function pointer to receive message

Remarks
Whenever a file or directory is created, deleted, uploaded and moved, callback function
is called.
ND2_CALLBACK_MSG prototype is following.

typedef void(*ND2_CALLBACK_MSG)(char *LPCSTR);


LPCSTR is a message and UTF8 encoded null terminated string from file system. The
message format is JSON format and following.
method Occurred file operation. create/delete/upload/move
result success or fail
msg Description
object path Path of file or directory
15

dir True or False. If it is file, this is value is false.
size Size of the file. if it is directory, key size is not exist.

Example
When a file is delete.

{"msg": "", "object": {"path": "F:\\music\\a.txt", "dir": false, "size": 4}, "method": "delete",
"result": "success"}

You might also like