'자작소스/C++/MFC/API'에 해당되는 글 6건
- 2016.05.10 AES128 CBC PKCS5 HMAC(SHA256) 암/복호화(C++)
- 2014.12.05 AES CBC 128BIT PKCS5 암/복호화(C++)
- 2009.03.23 리스트 형태의 자료구조를 퀵소트로 정렬
- 2009.03.23 UDP를 이용한 간단한 FTP 서버/클라이언트
- 2009.03.23 꼬꼬마때 만든 성적처리 C++
- 2008.12.20 DB에서 그룹을 읽어 CTreeView 로 뿌리기
1. 헤더파일
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #ifndef UTILS_CRYPTO_H #define UTILS_CRYPTO_H #include <string> #include <stdio.h> #include "os/Compat.h" #include "cryptopp/config.h" class UtilsCrypto { public: UtilsCrypto(void); ~UtilsCrypto(void); static void hex2byte(const char *in, _UInt32 len, byte *out); static std::string MD5HASH(std::string); static std::string SHA256HASH(std::string); static std::string encrypt(std::string); static std::string decrypt(std::string); }; #endif |
2. cpp파일
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | #define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 #include "UtilsCrypto.h" #include "cryptopp/cryptlib.h" #include "cryptopp/modes.h" #include "cryptopp/aes.h" #include "cryptopp/filters.h" #include "cryptopp/base64.h" #include "cryptopp/md5.h" #include "cryptopp/hex.h" #include "cryptopp/sha.h" #include "cryptopp/hmac.h" UtilsCrypto::UtilsCrypto(void) { } UtilsCrypto::~UtilsCrypto(void) { } void UtilsCrypto::hex2byte(const char *in, _UInt32 len, byte *out) { for(_UInt32 i = 0; i < len; i+=2) { char c0 = in[i+0]; char c1 = in[i+1]; byte c = ( ((c0 & 0x40 ? (c0 & 0x20 ? c0 - 0x57 : c0 - 0x37) : c0 - 0x30) << 4) | ((c1 & 0x40 ? (c1 & 0x20 ? c1 - 0x57 : c1 - 0x37) : c1 - 0x30)) ); out[i/2] = c; } } std::string UtilsCrypto::MD5HASH(std::string str) { CryptoPP::Weak::MD5 hash; byte digest[CryptoPP::Weak::MD5::DIGESTSIZE]; hash.CalculateDigest(digest, (byte*)str.c_str(), str.length()); CryptoPP::HexEncoder encoder; std::string output; encoder.Attach(new CryptoPP::StringSink(output)); encoder.Put(digest, sizeof(digest)); encoder.MessageEnd(); return output; } std::string UtilsCrypto::SHA256HASH(std::string str) { byte const* pbData = (byte*)str.data(); _UInt32 nDataLen = str.size(); byte abDigest[CryptoPP::SHA256::DIGESTSIZE]; CryptoPP::SHA256().CalculateDigest(abDigest, pbData, nDataLen); return std::string((char*)abDigest, 32); } std::string UtilsCrypto::encrypt(std::string str) { if (str.empty()) return std::string(); std::string enc_key = MD5HASH("비밀키"); std::string enc_iv = MD5HASH("IV키"); std::string enc_hash = MD5HASH("HMAC키"); //키할당 byte key[CryptoPP::AES::DEFAULT_KEYLENGTH]; memset(key, 0x00, CryptoPP::AES::DEFAULT_KEYLENGTH); const char* rawKey = enc_key.c_str(); hex2byte(rawKey, strlen(rawKey), key); //iv할당 byte iv[CryptoPP::AES::BLOCKSIZE]; memset(iv, 0x00, CryptoPP::AES::BLOCKSIZE); const char* rawIv = enc_iv.c_str(); hex2byte(rawIv, strlen(rawIv), iv); //hash키할당 byte hashKey[CryptoPP::AES::DEFAULT_KEYLENGTH]; memset(hashKey, 0x00, CryptoPP::AES::DEFAULT_KEYLENGTH); const char* rawHashKey = enc_hash.c_str(); hex2byte(rawHashKey, strlen(rawHashKey), hashKey); std::string cipher, hmac, encoded; try { CryptoPP::CBC_Mode<CryptoPP::AES>::Encryption e; e.SetKeyWithIV(key, sizeof(key), iv); CryptoPP::StringSource ss(str, true, new CryptoPP::StreamTransformationFilter(e, new CryptoPP::StringSink(cipher), CryptoPP::BlockPaddingSchemeDef::PKCS_PADDING)); CryptoPP::HMAC<CryptoPP::SHA256> hmac_hash(hashKey, sizeof(hashKey)); CryptoPP::StringSource(cipher, true, new CryptoPP::HashFilter(hmac_hash, new CryptoPP::StringSink(hmac))); CryptoPP::StringSource(cipher + hmac, true, new CryptoPP::Base64Encoder(new CryptoPP::StringSink(encoded), false)); return encoded; } catch (const CryptoPP::Exception &e) { std::cerr << e.what() << std::endl; return std::string(); } } std::string UtilsCrypto::decrypt(std::string str) { if (str.empty()) return std::string(); std::string enc_key = MD5HASH("비밀키"); std::string enc_iv = MD5HASH("IV키"); std::string enc_hash = MD5HASH("HMAC키"); //키할당 byte key[CryptoPP::AES::DEFAULT_KEYLENGTH]; memset(key, 0x00, CryptoPP::AES::DEFAULT_KEYLENGTH); const char* rawKey = enc_key.c_str(); hex2byte(rawKey, strlen(rawKey), key); //iv할당 byte iv[CryptoPP::AES::BLOCKSIZE]; memset(iv, 0x00, CryptoPP::AES::BLOCKSIZE); const char* rawIv = enc_iv.c_str(); hex2byte(rawIv, strlen(rawIv), iv); //hash키할당 byte hashKey[CryptoPP::AES::DEFAULT_KEYLENGTH]; memset(hashKey, 0x00, CryptoPP::AES::DEFAULT_KEYLENGTH); const char* rawHashKey = enc_hash.c_str(); hex2byte(rawHashKey, strlen(rawHashKey), hashKey); std::string tmp, cipher, hmac, hmac2, decoded; try { CryptoPP::StringSource(str, true, new CryptoPP::Base64Decoder(new CryptoPP::StringSink(tmp))); if (tmp.size() < 48) return std::string(); cipher = tmp.substr(0, tmp.size() - 32); hmac = tmp.substr(tmp.size() - 32, 32); CryptoPP::HMAC<CryptoPP::SHA256> hmac_hash(hashKey, sizeof(hashKey)); CryptoPP::StringSource(cipher, true, new CryptoPP::HashFilter(hmac_hash, new CryptoPP::StringSink(hmac2))); if (hmac.compare(hmac2) != 0) return std::string(); CryptoPP::CBC_Mode<CryptoPP::AES>::Decryption d; d.SetKeyWithIV(key, sizeof(key), iv); CryptoPP::StringSource ss(cipher, true, new CryptoPP::StreamTransformationFilter(d, new CryptoPP::StringSink(decoded), CryptoPP::BlockPaddingSchemeDef::PKCS_PADDING)); return decoded; } catch(const CryptoPP::Exception &e) { std::cerr << e.what() << std::endl; return std::string(); } } |
Crypto++ 라이브러리를 이용함 암/복호화
(AES CBC 128BIT PKCS5)
#include "UtilsCrypto.h" //헤더는 별내용 없음 #include "cryptopp/cryptlib.h" #include "cryptopp/modes.h" #include "cryptopp/aes.h" #include "cryptopp/filters.h" #include "cryptopp/base64.h" #include "cryptopp/md5.h" #include "cryptopp/hex.h" UtilsCrypto::UtilsCrypto(void) { } UtilsCrypto::~UtilsCrypto(void) { } void UtilsCrypto::hex2byte(const char *in, _UInt32 len, byte *out)
{ for(_UInt32 i = 0; i < len; i+=2) { char c0 = in[i+0]; char c1 = in[i+1]; byte c = ( ((c0 & 0x40 ? (c0 & 0x20 ? c0 - 0x57 : c0 - 0x37) : c0 - 0x30) << 4) | ((c1 & 0x40 ? (c1 & 0x20 ? c1 - 0x57 : c1 - 0x37) : c1 - 0x30)) ); out[i/2] = c; } } std::string UtilsCrypto::MD5HASH(std::string str)
{ CryptoPP::MD5 hash; byte digest[CryptoPP::MD5::DIGESTSIZE]; hash.CalculateDigest(digest, (byte*)str.c_str(), str.length()); CryptoPP::HexEncoder encoder; std::string output; encoder.Attach(new CryptoPP::StringSink(output)); encoder.Put(digest, sizeof(digest)); encoder.MessageEnd(); return output; } std::string UtilsCrypto::encrypt(std::string str)
{ std::string enc_key = MD5HASH("암호키"); std::string enc_iv = MD5HASH("iv키"); //키할당 byte key[CryptoPP::AES::DEFAULT_KEYLENGTH]; memset(key, 0x00, CryptoPP::AES::DEFAULT_KEYLENGTH); const char* rawKey = enc_key.c_str(); hex2byte(rawKey, strlen(rawKey), key); //iv할당 byte iv[CryptoPP::AES::BLOCKSIZE]; memset(iv, 0x00, CryptoPP::AES::BLOCKSIZE); const char* rawIv = enc_iv.c_str(); hex2byte(rawIv, strlen(rawIv), iv); std::string cipher, encoded; try { CryptoPP::CBC_Mode<CryptoPP::AES>::Encryption e; e.SetKeyWithIV(key, sizeof(key), iv); CryptoPP::StringSource ss(str, true, new CryptoPP::StreamTransformationFilter(e, new CryptoPP::StringSink(cipher), CryptoPP::BlockPaddingSchemeDef::PKCS_PADDING)); CryptoPP::StringSource(cipher, true, new CryptoPP::Base64Encoder(new CryptoPP::StringSink(encoded), false)); //base64encoder 두번째 인자에 false를 줘야 마지막애 개행문자가 추가안됨 return encoded; } catch(const CryptoPP::Exception& e) { std::cerr << e.what() << std::endl; return NULL; } } std::string UtilsCrypto::decrypt(std::string str)
{ std::string enc_key = MD5HASH("암호키"); std::string enc_iv = MD5HASH("iv키"); //키할당 byte key[CryptoPP::AES::DEFAULT_KEYLENGTH]; memset(key, 0x00, CryptoPP::AES::DEFAULT_KEYLENGTH); const char* rawKey = enc_key.c_str(); hex2byte(rawKey, strlen(rawKey), key); //iv할당 byte iv[CryptoPP::AES::BLOCKSIZE]; memset(iv, 0x00, CryptoPP::AES::BLOCKSIZE); const char* rawIv = enc_iv.c_str(); hex2byte(rawIv, strlen(rawIv), iv); std::string cipher, decoded; try { CryptoPP::CBC_Mode<CryptoPP::AES>::Decryption d; d.SetKeyWithIV(key, sizeof(key), iv); CryptoPP::StringSource(str, true, new CryptoPP::Base64Decoder(new CryptoPP::StringSink(cipher))); CryptoPP::StringSource ss(cipher, true, new CryptoPP::StreamTransformationFilter(d, new CryptoPP::StringSink(decoded), CryptoPP::BlockPaddingSchemeDef::PKCS_PADDING)); return decoded; } catch(const CryptoPP::Exception& e) { std::cerr << e.what() << std::endl; return NULL; } }
파일에서 읽어들인 데이타를 리스트 형태로 저장하고 퀵소트를 이용하여 정렬 하는 소스
#include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <string.h> int i=0; typedef struct node { int val; struct node *next; } NODE; void releaseList(NODE *list); void printList(NODE *list); NODE *getListBeforeNode(NODE *list, int pos); NODE *getListNode(NODE *list, int pos); void swapListNode(NODE *list, int pos1, int pos2); void QuickSort(NODE *list, int spos, int epos); int main(int argc, char* argv[]) { FILE *fp; // 파일포인터 NODE *node; NODE *next_node; char string_buf[20] = {'\0'}; // 문자열 버퍼(2자리 이상도 가능하게) char char_buf[2] = {'\0'}; // 문자버퍼 int number_count = 0; //데이타 파일 파일오픈 fp = fopen("data","r"); if(fp == NULL) { printf("file open failed\n\n"); system("pause"); exit(0); } while(!feof(fp)) { fread(char_buf, sizeof(char), 1, fp); if(char_buf[0] == ' ') { node = (NODE *) malloc(sizeof(NODE)); node->val = strtol(string_buf, NULL, 10); if(number_count == 0) node->next = NULL; else node->next = next_node; next_node = node; memset(string_buf, '\0', 20); memset(string_buf, '\0', 2); number_count++; } else if(!feof(fp)) { strcat(string_buf, char_buf); } } fclose(fp); if(strlen(string_buf) > 0) { node = (NODE *) malloc(sizeof(NODE)); node->val = strtol(string_buf, NULL, 10); node->next = next_node; next_node = node; number_count++; } //헤드노드 node = (NODE *) malloc(sizeof(NODE)); node->val = NULL; node->next = next_node; printList(node); QuickSort(node, 1, number_count); printf("\n\n"); printList(node); releaseList(node); system("pause"); return 0; } void releaseList(NODE *list) { if(list->next != NULL) { releaseList(list->next); free(list->next); return; } else { return; } } void printList(NODE *list) { if(list->val != NULL) printf("%d\n", list->val); if(list->next != NULL) printList(list->next); else return; } NODE *getListBeforeNode(NODE *list, int pos) { if(pos <= 1 || list->next == NULL) return list; else return getListBeforeNode(list->next, pos-1); } NODE *getListNode(NODE *list, int pos) { if(pos == 0 || list->next == NULL) return list; else return getListNode(list->next, pos-1); } void swapListNode(NODE *list, int pos1, int pos2) { NODE *next1; NODE *next2; NODE *next3; NODE *next4; NODE tmp; next1 = getListBeforeNode(list, pos1); next2 = getListNode(list, pos1); next3 = getListBeforeNode(list, pos2); next4 = getListNode(list, pos2); tmp.next = next1->next; next1->next = next3->next; next3->next = tmp.next; tmp.next = next2->next; next2->next = next4->next; next4->next = tmp.next; } void QuickSort(NODE *list, int spos, int epos) { int left,right,key; if ( !(spos < epos) ) return; key=getListNode(list, epos)->val; left=spos-1; right=epos; while(left < right ) { while (getListNode(list, ++left)->val < key); while (getListNode(list, --right)->val > key); if (left >= right) break; swapListNode(list, left, right); } swapListNode(list, left, epos); QuickSort(list, spos, left-1); QuickSort(list, left+1, epos); }
학교 다닐때 만들었던 UDP 프로토콜을 이용한 FTP 서버/클라이언트 콘솔 프로그램인데...
소스를 살펴보니 허접.. ㅋㅋ
사용법(서버) : UDPEchoServer.exe 포트번호
사용법(클라) : UDPEchoClient.exe 서버아이피 포트번호
클라이언트 지원명령 : dir, get, put
컴퓨터를 뒤지다보니 아주 예전에 만들었던 성적 처리 C++ 소스를 찾았는데 지금 보면 쬐끔 엉성한것 같기도...
~(ㅡ``ㅡ)~
문제 : 3명의 학번,이름,국어,수학,영어 점수를 입력받아 평균을 처리하고 양식에 맞게 화면 및 파일로 출력하시오.
내가 맹근 소스
#include <iostream> #include <fstream> #include <time.h> using namespace std; class score { private: char *id_num; // 학번 char *name; // 이름 protected: double kor; // 국어 점수 double math; // 수학 점수 double eng; // 영어 점수 double ave; // 세 과목의 평균 public: score(); score(char *_id_num, char *_name, double _kor, double _math, double _eng); // 생성자 ~score(); void initStuData(char *_id_num, char *_name, double _kor, double _math, double _eng); // 객체 초기화 메소드 double getScoreByKor(); double getScoreByMath(); double getScoreByEng(); double getScoreByAve(); void printScore(); void writeScore(char *filename); }; class tot_score : public score { // 계승 private: double tot_ave; // 모든 과목의 전체 평균 // 각 과목의 평균은 계승받은 // 멤버 데이터의 kor, math, eng 사용 public: tot_score(); ~tot_score() {} void getStuData(score &obj); void calcStuData(int stuNum); void printStuAvg(); void writeStuAvg(char *filename); }; score::score() { // 객체 초기화시 기본 정보로 초기화 id_num = new char[2]; name = new char[9]; strcpy(id_num,"0"); strcpy(name,"정보없음"); kor = 0.0f; math = 0.0f; eng = 0.0f; ave = 0.0f; } score::score(char *_id_num, char *_name, double _kor, double _math, double _eng) { // 생성자 에서 각각 데이타로 초기화 id_num = new char[strlen(_id_num)+1]; name = new char[strlen(_name)+1]; strcpy(id_num,_id_num); strcpy(name,_name); kor = _kor; math = _math; eng = _eng; ave = (_kor + _math + _eng) / 3 ; } score::~score() { // 사용한 독적 배열을 해제 delete [] id_num; delete [] name; } void score::initStuData(char *_id_num, char *_name, double _kor, double _math, double _eng) { // 별도의 초기화 메소드 id_num = new char[strlen(_id_num)+1]; name = new char[strlen(_name)+1]; strcpy(id_num,_id_num); strcpy(name,_name); kor = _kor; math = _math; eng = _eng; ave = (_kor + _math + _eng) / 3 ; } double score::getScoreByKor() { // 국어 점수 리턴 return kor; } double score::getScoreByMath() { // 수학 점수 리턴 return math; } double score::getScoreByEng() { // 영어점수 리턴 return eng; } double score::getScoreByAve() { // 평균 리턴 return ave; } void score::printScore() { // 학생의 성적 정보를 화면에 출력 cout << "학생성적정보" << endl; cout << "아이디 : " << id_num << endl; cout << "이름 : " << name << endl; cout << "국어 : " << kor << endl; cout << "수학 : " << math << endl; cout << "영어 : " << eng << endl; cout << "평균 : " << ave << endl << endl; } void score::writeScore(char *filename = "stuTotAvg.dat") { // 학생의 성적 정보를 파일로 저장 ofstream fp; fp.open(filename,ios_base::out | ios_base::app); // "추가" 모드로 파일을 오픈 fp << "학생성적정보" << endl; fp << "아이디 : " << id_num << endl; fp << "이름 : " << name << endl; fp << "국어 : " << kor << endl; fp << "수학 : " << math << endl; fp << "영어 : " << eng << endl; fp << "평균 : " << ave << endl << endl; fp.close(); } tot_score::tot_score() { // 객체 생성시 초기화 kor = 0.0f; math = 0.0f; eng = 0.0f; tot_ave = 0.0f; } void tot_score::getStuData(score &obj){ // score 객체를 받아 총점을 누적 kor += obj.getScoreByKor(); math += obj.getScoreByMath(); eng += obj.getScoreByEng(); tot_ave += obj.getScoreByAve(); } void tot_score::calcStuData(int stuNum) { // 총점에서 평균을 구함 kor = kor / stuNum; math = math / stuNum; eng = eng / stuNum; tot_ave = tot_ave / stuNum; } void tot_score::printStuAvg() { // 과목평균,총평균을 화면에 출력 cout << "과목 평균" << endl; cout << "국어 : " << kor << endl; cout << "수학 : " << math << endl; cout << "영어 : " << eng << endl; cout << "총평균 : " << tot_ave << endl; } void tot_score::writeStuAvg(char *filename = "stuTotAvg.dat") { // 과목균,총평균을 파일로 저장 ofstream fp; fp.open(filename,ios_base::out | ios_base::app); fp << "과목 평균" << endl; fp << "국어 : " << kor << endl; fp << "수학 : " << math << endl; fp << "영어 : " << eng << endl; fp << "총평균 : " << tot_ave << endl; fp.close(); } int main() { char id_name[10]; // 입력받은 데이타를 저장할 임시 변수들 char name[10]; double kor = 0.0f; double math = 0.0f; double eng = 0.0f; int stuNum = 0; // 평균을 처리할 학생수 저장 char filename[100]; // 평균을 저장할 파일명 time_t now; struct tm *now_day_time; time(&now); now_day_time = localtime(&now); strftime(filename,100,"score%Y%m%d%H%M%S.dat",now_day_time); // 파일명을 "score년월일시분초.dat"로 설정 printf("3명의 학생정보를 입력해주세요.\n학번 이름 국어 수학 영어\n"); score stu1,stu2,stu3; // try문 내에서 객체 생성시 블럭 밖에서는 객제가 존재하지 않아 try문 밖에서 생성 try { cin >> id_name >> name; // 정보를 입력 받으며 예외 처리를 함 cin >> kor; if(cin.fail()) throw 1; cin >> math; if(cin.fail()) throw 2; cin >> eng; if(cin.fail()) throw 3; stu1.initStuData(id_name,name,kor,math,eng); // 입력 받은 정보를 이용해 객체 초기화 cin >> id_name >> name; cin >> kor; if(cin.fail()) throw 1; cin >> math; if(cin.fail()) throw 2; cin >> eng; if(cin.fail()) throw 3; stu2.initStuData(id_name,name,kor,math,eng); cin >> id_name >> name; cin >> kor; if(cin.fail()) throw 1; cin >> math; if(cin.fail()) throw 2; cin >> eng; if(cin.fail()) throw 3; stu3.initStuData(id_name,name,kor,math,eng); } catch(int e) { switch(e) { case 1 : printf("kor 점수 입력이 잘못 되었습니다.\n"); break; case 2 : printf("math 점수 입력이 잘못 되었습니다.\n"); break; case 3 : printf("eng 점수 입력이 잘못 되었습니다.\n"); break; } return 0; } tot_score stuTot; // 각 점수 객체들을 tot_score 로 넘겨 점수를 누적 stuTot.getStuData(stu1); stuNum++; stuTot.getStuData(stu2); stuNum++; stuTot.getStuData(stu3); stuNum++; stuTot.calcStuData(stuNum); // 평균을 구함 stu1.printScore(); // 정보를 화면에 출력 stu2.printScore(); stu3.printScore(); stuTot.printStuAvg(); stu1.writeScore(filename); // 정보를 파일로 출력 stu2.writeScore(filename); stu3.writeScore(filename); stuTot.writeStuAvg(filename); system("pause"); return 0; }
액세스로 간단히 구성해 봤는데 테이블은 이미지와 같다.
id 는 PK 이고 div_id 는 부모의 id 값이고 is_last_node 는 말단 노드인지 표시하는 필드다.
소스코드는 아래와 같다.
CTreeView::OnInitialUpdate();
//이미지 리스트 생성
CImageList il;
il.Create(IDB_BITMAP1, 16, 1, RGB(255, 255, 255));
CTreeCtrl& tree = GetTreeCtrl();
tree.SetImageList(&il, TVSIL_NORMAL);
il.Detach();
HTREEITEM hGrp = tree.InsertItem("대학교", 0, 0, TVI_ROOT, TVI_LAST);
CString csId;
csId.LoadString(IDS_DB_DSN);
CDatabase db;
db.OpenEx(csId,0);
CRecordset rs(&db);
rs.Open(CRecordset::dynaset, "SELECT COUNT(*) FROM tbl_group");
rs.GetFieldValue(short(0),csId);
rs.Close();
if(csId.Compare("0") != 0) {
int cnt,cnt1;
cnt = _ttoi(csId);
HTREEITEM* hGrp1 = new HTREEITEM[cnt];
rs.Open(CRecordset::dynaset, "SELECT * FROM tbl_group ORDER BY div_id ASC");
CString csName,csDivId,csNextDivId;
while(!rs.IsEOF()) {
rs.GetFieldValue(short(0),csId);
rs.GetFieldValue(short(1),csName);
rs.GetFieldValue(short(2),csDivId);
rs.GetFieldValue(short(3),csNextDivId);
cnt = _ttoi(csDivId);
cnt1 = _ttoi(csId);
if(csDivId.Compare("0") == 0 && csNextDivId.Compare("0") == 0)
hGrp1[--cnt1] = tree.InsertItem(csName, 1, 1, hGrp, TVI_LAST);
else if(csDivId.Compare("0") == 0 && csNextDivId.Compare("0") != 0)
hGrp1[--cnt1] = tree.InsertItem(csName, 2, 2, hGrp, TVI_LAST);
else if(csNextDivId.Compare("0") == 0)
hGrp1[--cnt1] = tree.InsertItem(csName, 1, 1, hGrp1[--cnt], TVI_LAST);
else
hGrp1[--cnt1] = tree.InsertItem(csName, 2, 2, hGrp1[--cnt], TVI_LAST);
rs.MoveNext();
}
rs.Close();
delete [] hGrp1;
}
db.Close();
출력화면