× Home


Features


Download


Purchase


API


Support

GetDeviceDataDump function

Dumps device data into a file (same as "Dump device data to a file..." button in the MTPdrive Settings application - see here).

Syntax

int __stdcall GetDeviceDataDump(
  LPCWSTR psFileName
);

Parameters

psFileName

The file name where to save the device data into.

Return Value

If the function succeeds, the return value is zero and the psFileName contain the dumped diagnostic data.

If the function fails, the return value is negative number. See the Example for more details about possible error codes.

Requirements

The API function only works in registered version of the MTPdrive. If called in trial version the API function returns error code -2.

Example

#include <windows.h>
#include <stdio.h>

typedef int(__stdcall *GETDEVICEDATADUMP)(LPCWSTR psFileName);

//---------------------------------------------------------------------------
// API error codes
//---------------------------------------------------------------------------
#define MTPDRIVEAPI_ERROR_SUCCESS           0
#define MTPDRIVEAPI_ERROR_FAILURE          -1
#define MTPDRIVEAPI_ERROR_NOLICENSE        -2
#define MTPDRIVEAPI_ERROR_INVALIDARG       -3
#define MTPDRIVEAPI_ERROR_INVALIDDRV       -4
#define MTPDRIVEAPI_ERROR_CANNOTCREATEFILE -5

int main(int argc, char* argv[])
{
  HMODULE hDll;
  int nResult = 0;
  LPWSTR* argvW = CommandLineToArgvW(GetCommandLineW(), &argc);
  if (!argvW || argc != 2)
  {
    printf("Usage: APItestGetDeviceDataDump.exe outputFileName\n");
    LocalFree(argvW);
    return 1;
  }

  SetDllDirectory("c:\\Program Files\\MTPdrive");
  hDll = LoadLibrary("MTPdrive.dll");
  if (hDll)
  {
    GETDEVICEDATADUMP pGetDeviceDataDump = (GETDEVICEDATADUMP)GetProcAddress(hDll, "GetDeviceDataDump");
    if (pGetDeviceDataDump)
    {
      nResult = pGetDeviceDataDump(argvW[1]);
      printf("Result: %d\n", nResult);
    }
    else
    {
      printf("Cannot load function GetDeviceDataDump\n");
      nResult = 2;
    }
    FreeLibrary(hDll);
  }
  else
  {
    printf("Cannot load library MTPdrive.dll\n");
    nResult = 3;
  }
  LocalFree(argvW);
  return nResult;
}
         

See Also