base
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{2FCF637F-16AB-4FE4-940C-0475A2D9D04B}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CSharp_Support</RootNamespace>
|
||||
<AssemblyName>CSharp_Support</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>2.0</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\win32\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\win32\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>..\win32\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\win64\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||
<OutputPath>..\win64\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,80 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{2FCF637F-16AB-4FE4-940C-0475A2D9D04B}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CSharp_Support</RootNamespace>
|
||||
<AssemblyName>CSharp_Support</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\win32\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\win32\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>..\win32\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\win64\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||
<OutputPath>..\win64\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,85 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{2FCF637F-16AB-4FE4-940C-0475A2D9D04B}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CSharp_Support</RootNamespace>
|
||||
<AssemblyName>CSharp_Support</AssemblyName>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>2.0</OldToolsVersion>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\win32\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\win32\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>..\win32\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\win64\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||
<OutputPath>..\win64\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,205 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
// 마샬링을 위해 꼭!! 들어가야 하는 namespace입니다.
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace CSharp_Support
|
||||
{
|
||||
// kernel32.dll을 활용해서 unmanaged dll을 명시적으로 로드하기위한 클래스입니다.
|
||||
static class NativeMethods
|
||||
{
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr LoadLibrary(string dllToLoad);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern bool FreeLibrary(IntPtr hModule);
|
||||
}
|
||||
|
||||
class Program
|
||||
{
|
||||
// SSDK의 sh_get_service_host 함수의 타입을 정의하는 delegate선언.
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate IntPtr sh_get_service_host(string szUserID, string password, string serviceId);
|
||||
|
||||
// SSDK의 sh_get_auth_string 함수의 타입을 정의하는 delegate선언.
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate IntPtr sh_get_auth_string(string userId, string password, string serviceId
|
||||
, string authKey, string authfile, Int64 expire);
|
||||
|
||||
// csdk의 sh_init 세번째 파라메터로 넘겨줄 함수포인터형 delegate선언.
|
||||
public delegate int sh_callback(IntPtr param, Int64 progress);
|
||||
|
||||
// csdk의 sh_init 함수의 타입을 정의하는 delegate선언.
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate IntPtr sh_init(string url, string authString, sh_callback proc, IntPtr param);
|
||||
|
||||
// csdk의 sh_download 함수의 타입을 정의하는 delegate선언.
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate int sh_download(IntPtr hcsdk, string srcPath, string dstPath, int writePolicy, Int64 availQuota);
|
||||
|
||||
// csdk의 sh_free 함수의 타입을 정의하는 delegate선언.
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate int sh_upload(IntPtr hcsdk, string srcPath, string dstPath, int writePolicy, Int64 availQuota);
|
||||
|
||||
// csdk의 sh_get_error_number 함수의 타입을 정의하는 delegate선언.
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate int sh_get_error_number(IntPtr hcsdk);
|
||||
|
||||
// csdk의 sh_get_error_message 함수의 타입을 정의하는 delegate선언.
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate IntPtr sh_get_error_message(IntPtr hcsdk);
|
||||
|
||||
// csdk의 sh_free 함수의 타입을 정의하는 delegate선언.
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private delegate void sh_free(IntPtr hcsdk);
|
||||
|
||||
// 고객 가입시 안내되는 접속정보 및 cert파일 정보.
|
||||
// --> 기존에 서비스가 되고 있던 사이트로 알고 있습니다.
|
||||
// 각 변수에 적당한 값들을 넣어주시면 되겠습니다.
|
||||
// 혹, 정확한 입력값을 모르실경우 운영팀에 요청하시면 됩니다.
|
||||
/*
|
||||
public const string szService = "";
|
||||
public const string szID = "";
|
||||
public const string szPwd = "";
|
||||
public const string szAuth = "";
|
||||
public const string szCertPath = "";
|
||||
*/
|
||||
|
||||
public const string szService = "svc1bd04";
|
||||
public const string szID = "solboxsvc1";
|
||||
public const string szPwd = "5emffld)";
|
||||
public const string szAuth = "svc1bd04";
|
||||
public const string szCertPath = "D:/cert/solboxsvc1298.cert";
|
||||
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//1. 제공된 sdk에서 테스트 구현에 필요한 함수들만 마샬링한다.
|
||||
// -> 제공된 sdk설명서를 참조하고 추가적으로 필요한 함수들은
|
||||
// 아래 함수들처럼 마샬링처리 후에 사용하면된다.
|
||||
//SSdk.dll을 로드하기 위한 구문.
|
||||
IntPtr pSsdkDll = NativeMethods.LoadLibrary(@"SHSSDK.dll");
|
||||
//CSdk.dll을 로드하기 위한 구문.
|
||||
IntPtr pCsdkDll = NativeMethods.LoadLibrary(@"SHCSDK.dll");
|
||||
|
||||
// ProcAddress를 얻어올 변수이다.
|
||||
// temporary 형태로 사용 할 수 있으므로, 한번 선언해서 계속 제사용 하면된다.
|
||||
IntPtr pAddressOfFunctionToCall;
|
||||
|
||||
// NativeMethods를 활용해 dll에서 함수포인터를 얻는다.
|
||||
pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pSsdkDll, "sh_get_service_host");
|
||||
// 취득한 함수 포인터를 Marshalling 단계를 거친다.
|
||||
sh_get_service_host sh_get_service_host = (sh_get_service_host)Marshal.GetDelegateForFunctionPointer(
|
||||
pAddressOfFunctionToCall,
|
||||
typeof(sh_get_service_host));
|
||||
|
||||
pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pSsdkDll, "sh_get_auth_string");
|
||||
sh_get_auth_string sh_get_auth_string = (sh_get_auth_string)Marshal.GetDelegateForFunctionPointer(
|
||||
pAddressOfFunctionToCall,
|
||||
typeof(sh_get_auth_string));
|
||||
|
||||
pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pCsdkDll, "sh_init");
|
||||
sh_init sh_init = (sh_init)Marshal.GetDelegateForFunctionPointer(
|
||||
pAddressOfFunctionToCall,
|
||||
typeof(sh_init));
|
||||
|
||||
pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pCsdkDll, "sh_download");
|
||||
sh_download sh_download = (sh_download)Marshal.GetDelegateForFunctionPointer(
|
||||
pAddressOfFunctionToCall,
|
||||
typeof(sh_download));
|
||||
|
||||
pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pCsdkDll, "sh_get_error_number");
|
||||
sh_get_error_number sh_get_error_number = (sh_get_error_number)Marshal.GetDelegateForFunctionPointer(
|
||||
pAddressOfFunctionToCall,
|
||||
typeof(sh_get_error_number));
|
||||
|
||||
pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pCsdkDll, "sh_get_error_message");
|
||||
sh_get_error_message sh_get_error_message = (sh_get_error_message)Marshal.GetDelegateForFunctionPointer(
|
||||
pAddressOfFunctionToCall,
|
||||
typeof(sh_get_error_message));
|
||||
|
||||
pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pCsdkDll, "sh_free");
|
||||
sh_free sh_free = (sh_free)Marshal.GetDelegateForFunctionPointer(
|
||||
pAddressOfFunctionToCall,
|
||||
typeof(sh_free));
|
||||
|
||||
pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pCsdkDll, "sh_upload");
|
||||
sh_upload sh_upload = (sh_upload)Marshal.GetDelegateForFunctionPointer(
|
||||
pAddressOfFunctionToCall,
|
||||
typeof(sh_upload));
|
||||
|
||||
// 2. 사용할 함수들에 대해 마샬링 처리를 한 후 sdk설명서를 참조해서 아래처럼
|
||||
// 구현에 사용하면 된다.
|
||||
// 추가 설명 : 마샬링된 함수들의 파라메터들은 대부분 char* 또는 int, int64등과
|
||||
// 같이 기본적은 변수 타입들이므로 적절한 변수타입으로 매칭시키면된다.
|
||||
// * 핸들과 pointer형 변수들은 IntPtr로 매칭하면 된다.
|
||||
|
||||
// 호스트 정보를 얻어온다.
|
||||
string host = Marshal.PtrToStringAnsi(sh_get_service_host(szID, szPwd, szService));
|
||||
Console.WriteLine(host);
|
||||
|
||||
|
||||
// c또는 c++에서 time(NULL)과 같은 값을 구하는 과정이다.
|
||||
DateTime d1 = new DateTime(1970, 1, 1);
|
||||
DateTime d2 = DateTime.Now;
|
||||
TimeSpan ts = new TimeSpan(d2.Ticks - d1.Ticks);
|
||||
int recordTime = Convert.ToInt32(ts.TotalSeconds);
|
||||
|
||||
// authstring을 얻어온다.
|
||||
string astring = Marshal.PtrToStringAnsi(sh_get_auth_string(szID, szPwd, szService, szAuth, szCertPath, recordTime + 86400));
|
||||
|
||||
// csdk를 사용하기 위한 초기화단계.
|
||||
IntPtr hcsdk = sh_init(host, astring, new sh_callback(CallbackProc), IntPtr.Zero);
|
||||
|
||||
// 다운로드 테스트.
|
||||
// 2,3번째 다운로드 대상파일과 저장경로등은 적절히 변경하면된다.
|
||||
if (sh_download(hcsdk, "/SVC1_TEST/test_CSharp", "D:\\temp\\a1.xml", 1, -1) == 0)
|
||||
{
|
||||
Console.Write("sh_download ERROR :");
|
||||
Console.Write(sh_get_error_number(hcsdk));
|
||||
Console.Write(",");
|
||||
Console.WriteLine(Marshal.PtrToStringAnsi(sh_get_error_message(hcsdk)));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("sh_download SUCCESS\n");
|
||||
}
|
||||
|
||||
// 업로드 테스트.
|
||||
// 2,3번째 업로드 대상파일과 업로드경로등은 적절히 변경하면된다.
|
||||
if (sh_upload(hcsdk, "D:/test_10k.txt", "/SVC1_TEST/test_CSharp", 1, -1) == 0)
|
||||
{
|
||||
Console.Write("sh_upload ERROR :");
|
||||
Console.Write(sh_get_error_number(hcsdk));
|
||||
Console.Write(",");
|
||||
Console.WriteLine(Marshal.PtrToStringAnsi(sh_get_error_message(hcsdk)));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("sh_upload SUCCESS\n");
|
||||
}
|
||||
|
||||
// sh_init() 함수를 통해 얻은 sdk의 핸들은 꼭! 해제를 해야한다.
|
||||
sh_free(hcsdk);
|
||||
|
||||
// NativeMethods 클래스를 사용해 로드한 sdk들을 해제한다.
|
||||
bool resultSSdk = NativeMethods.FreeLibrary(pSsdkDll);
|
||||
bool resultCSdk = NativeMethods.FreeLibrary(pCsdkDll);
|
||||
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
// 콜백함수. __stdcall 형태로 콜링되도록 제공된다.
|
||||
public static int CallbackProc(IntPtr param, Int64 result)
|
||||
{
|
||||
Console.Write("Transfer : ");
|
||||
Console.WriteLine(result);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("CSharp_Support")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("CSharp_Support")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("1ac3f192-0e6e-4818-8f06-5f75f4ec9fc8")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user