SOL9 Sample: NetShareAdd

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * NetShareAdd.cpp 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// 2012/10/12 To run this program, you have to create a share folder "C:\sol".

#include <sol/nm/NetShare.h>

#include <sol/nm/ShareInfo2.h>

#include <sol/Locale.h>

void _tmain(int argc, TCHAR** argv)
{
  Locale locale;

  try {
    wchar_t* server = NULL;

    NetShare netShare(server);

    ShareInfo2 info2;
    info2.allocate();
      
    wchar_t* netName = L"SOL9_Share";

    //1 Try to remove a sharefolder of netName provided already exists

    try {
      printf("1 Try to delete a folder %S\n", netName);
      netShare.remove(netName);
  
    } catch (...) {
      ;// Ignore
    }

    SHARE_INFO_2* share = (SHARE_INFO_2*)info2.getBuffer();
    if (share) {
      share->shi2_netname = netName;   
      share->shi2_type    = STYPE_DISKTREE;
      share->shi2_remark  = L"SOL9 NetShare Sample";
      share->shi2_permissions = 0;
      share->shi2_max_uses = SHI_USES_UNLIMITED;

      share->shi2_current_uses = 0;
      share->shi2_path = L"C:\\sol";
      share->shi2_passwd = NULL;

      //2 Try to add a sharefolder of netName
      printf("2 Try to add a folder %S\n", netName);
      
      netShare.add(info2);
      printf("OK, NetShare added a share folder %S\n", netName);  
    }

  } catch (...) {
    printf("Exception \n");
  }

  printf("OK. Please hit [enter] key\n");
  getchar();
}

Last modified: 2 May 2016

Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.