目次
[MFC関連]
[C++/CLI]
・Nativeの構造体をラッピングする①(単純な構造体)
・Nativeの構造体をラッピングする②(固定長配列を含む構造体)
・Nativeの構造体をラッピングする③(ツリー型構造体)
[.NET Tips]
[ADO.NET]
[C#]
・[DataGridView]指定した行をソート対象外にする
・[DataGridView]チェックボックス付の列を追加する
・[Controll]簡単なBIN2ASCIIテキストボックス
[ビットマップ関連]
[C#]暗号化に対する方針
【メモ】
暗号化を使用する際は、独自のアルゴリズムは使用しない。
System.Security.Cryptographyを使用する。
MSDNのC#プログラミングガイド(セキュリティ)より
暗号化を使用する際は、独自のアルゴリズムは使用しない。
System.Security.Cryptographyを使用する。
MSDNのC#プログラミングガイド(セキュリティ)より
[C++/CLI]Nativeの構造体をラッピングする③
ツリー構造体のラッピング(構造体の中に構造体を含む)
※たぶんやり方はもっとスマートなのはあるはず。
/*
*Native(C言語)での構造体定義
*/
typedef struct tagTEST1
{
int i;
} TEST1;
typedef struct tagTEST2
{
unsigned char b;
} TEST2;
typedef struct tagTEST3
{
TEST1 t1;
TEST2 t2[4];
} TEST3;
/*
*C++/CLIでのラッピング
*/
public ref class M_TEST1
{
private:
TEST1 *st;
internal:
M_TEST1(TEST1 *st1)
{
st = st1;
}
~M_TEST1()
{
if (st != NULL)
{
delete st;
st = NULL;
}
}
public:
property int Member
{
int get() { return st->i; }
void set(int value) { st->i = value; }
}
};
public ref calss M_TEST2
{
private:
TEST2 *st;
internal:
M_TEST2(TEST2 *st2)
{
st = st2;
}
~M_TEST2()
{
if (st != NULL)
{
delete st;
st = NULL;
}
}
public:
property System::Byte Member
{
System::Byte get() { return st->b; }
void set(System::Byte value) { st->b = value; }
}
};
public ref class M_TEST3
{
private:
TEST3 *st;
M_TEST1^ m_t1;
array<M_TEST2^>^ m_t2;
public:
M_TEST3()
{
st = new TEST3()
m_t1 = gcnew M_TEST1(&st->t1);
m_t2 = gcnew array<M_TEST2^>(4);
for (int i = 0; i < 4; i++)
{
m_t2[i] = gcnew M_TEST2(&st->t2[i]);
}
}
~M_TEST3()
{
// 同じ
}
property M_TEST1^ mt1
{
M_TEST1^ get() { return m_t1; }
void set(M_TEST1^ value) { m_t1 = value; }
}
property array<M_TEST2^>^ mt2
{
array<M_TEST2^>^ get() { return m_t2; }
void set(array<M_TEST2^>^ value) { m_t2 = value; }
}
};
※たぶんやり方はもっとスマートなのはあるはず。
/*
*Native(C言語)での構造体定義
*/
typedef struct tagTEST1
{
int i;
} TEST1;
typedef struct tagTEST2
{
unsigned char b;
} TEST2;
typedef struct tagTEST3
{
TEST1 t1;
TEST2 t2[4];
} TEST3;
/*
*C++/CLIでのラッピング
*/
public ref class M_TEST1
{
private:
TEST1 *st;
internal:
M_TEST1(TEST1 *st1)
{
st = st1;
}
~M_TEST1()
{
if (st != NULL)
{
delete st;
st = NULL;
}
}
public:
property int Member
{
int get() { return st->i; }
void set(int value) { st->i = value; }
}
};
public ref calss M_TEST2
{
private:
TEST2 *st;
internal:
M_TEST2(TEST2 *st2)
{
st = st2;
}
~M_TEST2()
{
if (st != NULL)
{
delete st;
st = NULL;
}
}
public:
property System::Byte Member
{
System::Byte get() { return st->b; }
void set(System::Byte value) { st->b = value; }
}
};
public ref class M_TEST3
{
private:
TEST3 *st;
M_TEST1^ m_t1;
array<M_TEST2^>^ m_t2;
public:
M_TEST3()
{
st = new TEST3()
m_t1 = gcnew M_TEST1(&st->t1);
m_t2 = gcnew array<M_TEST2^>(4);
for (int i = 0; i < 4; i++)
{
m_t2[i] = gcnew M_TEST2(&st->t2[i]);
}
}
~M_TEST3()
{
// 同じ
}
property M_TEST1^ mt1
{
M_TEST1^ get() { return m_t1; }
void set(M_TEST1^ value) { m_t1 = value; }
}
property array<M_TEST2^>^ mt2
{
array<M_TEST2^>^ get() { return m_t2; }
void set(array<M_TEST2^>^ value) { m_t2 = value; }
}
};
[C++/CLI]Nativeの構造体をラッピングする②
構造体メンバに固定長配列を含む場合のラッピング
/*
*Native(C言語)での構造体定義
*/
typedef struct tagTEST2
{
unsigned char str[8];
unsigned long ulMember;
} TEST2;
/*
*C++/CLIでラッピングしたクラス
*/
public ref class M_TEST2
{
private:
TEST2 *st;
array<System::Byte>^ m_str;
public:
M_TEST2()
{
st = new TEST2();
m_str = gcnew array<System::Byte>(8);
}
~M_TEST2()
{
if (st != NULL)
{
delete st;
st = NULL;
}
}
property array<System::Byte>^ Str
{
array<System::Byte>^ get()
{
for (int i = 0; i < 8; i ++)
{
m_str[i] = st->str[i];
}
return m_str;
}
void set(array<System::Byte>^ value)
{
m_str = value;
for (int i = 0; i < 8; i++)
{
st->str[i] = m_str[i];
}
}
}
};
/*
*Native(C言語)での構造体定義
*/
typedef struct tagTEST2
{
unsigned char str[8];
unsigned long ulMember;
} TEST2;
/*
*C++/CLIでラッピングしたクラス
*/
public ref class M_TEST2
{
private:
TEST2 *st;
array<System::Byte>^ m_str;
public:
M_TEST2()
{
st = new TEST2();
m_str = gcnew array<System::Byte>(8);
}
~M_TEST2()
{
if (st != NULL)
{
delete st;
st = NULL;
}
}
property array<System::Byte>^ Str
{
array<System::Byte>^ get()
{
for (int i = 0; i < 8; i ++)
{
m_str[i] = st->str[i];
}
return m_str;
}
void set(array<System::Byte>^ value)
{
m_str = value;
for (int i = 0; i < 8; i++)
{
st->str[i] = m_str[i];
}
}
}
};