VisualStudio에서 소스를 관리할 수 있는 기능을 2가지 지원해주고 있다.


 하나는 Micro Soft에서 지원해주고 있는 MS Cloud이고, 또 다른 하나는 Git에서 지원해주는 GitHub이다.


 GitHub는 매달 7~21달러를 준다면, 숨김 기능을 사용할 수 있는 기능도 지원해주면서 더 많은 용량을 지원해주는 걸로 알고 있다.(MS Cloud도 유사하다.)


 여기서, 돈이 없고 사람들이 자주 사용하는 Git의 GitHub을 연동하는 방법을 기록하고자한다.

 


 '팀 탐색기' 라는 창이 있다.

 여기서  '팀 탐색기' 라는 곳에서 GitHub와 MS의 호스티드 서비스가 있게 된다.

 GitHub를 사용할려면 GitHub에 가입되어 있는 정보를 이용해서 가입이 되어 있어야 된다.

 즉, GitHub에 대한 가입을 처리해야된다.

 가입을 위해서 Sign up을 클릭한다.



 클릭하면, 위에 있는 사진처럼 해당 링크의 사이트로 이동이 된다.

 여기서, 가입을 하기 위해서 Sign up을 클릭하면 다음과 같은 페이지로 이동하게 된다.



 Join GitHub에 가입이 될 수 있게 뜨게 된다.

 여기서 UserName은 사용자의 닉네임을 뜻하게 되고, E-mail Address에서 설정이 될 것이다.

 Password라는 것은 가입을 하기 위해서 사용하는 비밀번호 설정이 되어 있다.



 Choose your plan이라는 것에서 어떤것을 사용할 것인지 표현되어 있다. 여기서 free라는 것을 사용하는 게 된다.



 'Connect...'을 클릭하면, GitHub에 연결하는 창이 띄워진다.

 여기서 GitHub에 회원가입에서 이메일을 사용하는데. 여기서 회원 가입이 마무리가 되면, 이메일에 확인 메일을 보내게 된다. 여기서 인증을 해야지만, 제대로된 회원가입이 되는 것이므로 인증 메일을 꼭 처리하길 바란다.


 여기서 로그인을 마무리하게 되면, 다음과 같은 창으로 변하게 된다.

 Clone은 GitHub에 올려져있는 프로젝트들을 복제해서 가지고오게 하는 것이고, Create는 Visual Studio에서 프로젝트를 작성하는 것이다.

 이것을 이용해서 프로젝트를 GitHub에 올리게 되고, 팀과 같이 소스 작성을 할 수 있게 되는 것이다.

Posted by JunkMam
,

 Windows 10으로 넘어가면서 MS(Micro Soft)에서 Visual Studio을 무료로 제공해주는 장치가 있다.

 참고로 소스를 편집 및 디버깅하는 툴또한 무료로 제공하고 있다.


 단, MS(Micro Soft)의 회원이어야지만 가능하다.


 그게 아니라면, 불가능하다. 하지만, 딱 1번만 로그인하면 승인이 떨어지므로 문제는 없다.


 딱 한번 설치한 후에 로그인을 해주자.(Skype 회원이면, 자동으로 지원이 가능하다.)


 마이크로 소프트 Visual Studio 설치 사이트 https://www.visualstudio.com/ko/


 참고로 Community에 대해서만 무료이다. 그 외에는 기능들이 지원의 차이가 확실히 나므로 돈이 들더라도 제대로 사용할려면, 이 제품을 안 쓰는 것도 낫다.(하지만, 그게 아니라면 문제는 없다.)


 


 해당 사이트에서 무료 다운로드는 Community 버전이다. Enterprise와는 확실히 차이가 있다.

 


 다운로드를 하면, 엄청나게 빠르게 다운로드가 되는것을 확인 할 수 있다.


 이유는 이것은 인터넷을 통해서 연결하기 위한 연결용 프로그램이고, 제대로된 설치 파일은 이 파일을 실행한 후에 제대로 작동이 된다.



 필자는 Visual Studio를 설치한 후에 다시 재설치하는 것이기 때문에 이 스샷이랑은 다를 수 있다.



 필자는 프로그래밍 언어를 전부 다 설치하고 다시 설치하는 것이기 때문에 39GByte가 되어 있지만, 정확하게는 약 60GByte가 된다.

 그래서 원하는 것만 설치하는 것이 중요하다.



 설치하는 중.


 이렇게 해서 Visual Studio가 설치가 되며, Unity 및 Cocos, Android 등이 설치가 되기 때문에 하나의 프로그램으로 대부분의 개발 환경을 조성하기 쉬워져 있다는 점에서 쓸만하다.(그렇다고 CodeBlocks로 IDE을 조성할 수 없다는 건 아니다. 단지 환경을 설정하기 위해서는 많은 것을 건들어야 된다.)


 그리고, 여기서 처음에 라이센스가 제대로 등록이 되어 있지 않아서 약 30일치의 평가판으로 동작하게 된다.


 도움말 > 제품 등록을 클릭해서 로그인을 딱 1번만해준다면, 이상없이 제품을 사용할 수 있게 됩니다.


 Visual Studio에서 윈도우 폰 등의 활발한 환경을 조성하기 위해서 Visual Studio에 일부분을 무료로 공개하여 사용할 수 있게 만든 것 같다.


 다음은 Visual Studio에서 다양한 개발자들이랑 소스를 공유하면서 개발할 수 있는 환경인 GitHub와 연동하는 방법을 작성할려고 한다.

Posted by JunkMam
,

 DuckCapture란, DuckLink에서 제작한 갈무리 스크린샷 프로그램이다.


 해당 프로그램은 단축키를 이용해서 전체화면/갈무리/특정 창 스크린 캡쳐/스크롤 스크린 캡쳐를 할 수 있는 프로그램이다.


 해당 프로그램은 SnagIt과 유사하고, 필자는 SnagIt을 대처할 프로그램을 찾다가 보니 이 프로그램을 찾게 되었다.


 참고로 SnagIt도 스크롤 스샷이 지원하고, 에디터도 지원한다.


 문제는 유료인 점인데. DuckCapture는 FreeWare라는 점에서 사용자에겐 이득이 아닐 수 없다.



 해당 설치 프로그램의 시작이다.



 DuckLink 사이트에서 구할려고 하지만, 해당 사이트에 들어가면, 제대로 안 들어가게 된다.


 링크 : http://www.ducklink.com/p/download/


 여기서 다운리 안된다는 점에서 문제이지만, DuckCapture을 구글링을 하면 구할 수는 있다.


 SnagIt과 유사하게 사용하는 것으로 세팅을 하는게 이득일 것이다.


Install_DuckCapture_2.7.exe


Posted by JunkMam
,

 Windows 10을 사용하면, 자동으로 One Drive가 자동으로 설치가 되어있다.


 하지만, 필자는 OneDrive등 Drive 계열의 소스들은 위에 있는 동기화를 사용하지 않고, Web Page를 이용하기 때문에 지웠다가. 다시 필요해져서 설치할려니 Windows 10이라서, 인스톨하는게 다운이 안 받아지는걸 확인했다.


 그래서 Reinstall하는 방법을 찾아보았다.


 그러다가 다음과 같은 페이지를 알게 되었다.


 링크 : https://answers.microsoft.com/en-us/windows/forum/windows_10-files/how-do-i-reinstall-onedrive-in-windows-10/ad738670-43c7-4ec3-9c87-f52425e19637


 이걸 이용해서 다시 reinstall하는 방법이 있다.


 이 방법은 다음과 같다.


 UserPath/AppData/Local/Microsoft/OneDrive/Updata/OneDriveSetup.exe


 여기에 있는 것을 이용하면, OneDriveSetUp이 설치가 되는걸 알 수 있다.

Posted by JunkMam
,

 소스코드가 많으면, 하나의 화면으로 읽거나 사용하기 어려운 경우가 있다.

 A4지가 넘쳐흐르는 필자는 소스를 분석하기 위해서 툴을 찾다가. 다음과 같은 툴을 찾게 되었다.


 SourcePrinter라고 하기도 하고, SourCodePrint RSP라고도 한다.


 윗쪽에는 수정 날짜와 프린터된 날짜가 있어서

 파일이 수정된 정보를 가지고 있고, 프린터된 날짜도 있어서 분석하기 쉽고,

 폰트 크기 설정과, 사용자의 정보 및 파일명과 파일의 페이지도 띄워져서 애무 편하다.

 그리고, 프린터가 2쪽 인쇄라서 종이를 아낄 수 있게 되고,(소스의 가독성을 위해서 탭과 줄 바꿈이 많아서 1면 1쪽 인쇄를 할경우 엄청난 종이 낭비가 발생한다.)


 적어도 적은 비용으로 많은 소스를 읽기 위해서는 2쪽 인쇄가 좋은 것이다.(그렇다고해서 가독성이 떨어질 수 있는 1명 4쪽 인쇄는 조금 조심해야된다.)


 그리고 컬러도 지원해준다는 점에서 이 프로그램이 꽤 도움이 많이된다.(필자는 흑백이라서 오히려 손해였지만, 컬러 프린터를 이용했을때는 엄청난 도움이 되었다.)


 프린터가 없는 사람은 어쩔수 없지만, PDF을 이용해서 보며 도움이 될것이다.


 

SourceCodePrintRSP131_K.zip


 도움이 되는 프로그램이라서 올린다.

Posted by JunkMam
,

 paperbak은 binary로 되어 있는 파일을 그림파일(Dot Matrix)형태로 바꿔서 저장할 수 있게 만드는 것을 말한다.


 참고로 paperbak은 bitmap과 종이에 QR코드랑 비슷하게 변환해서 데이터를 저장하게 만드는 것이다.


 해당 코드를 제작한 사이트는 다음과 같다.


 링크 : http://ollydbg.de/Paperbak/


 이것을 bitmap으로 변환되어 있는 것을 이용해서 photos에 저장하니, 문제 없이 무한 클라우드 처럼 사용을 할 수 있게 되었다.(참고로 이걸 이용해서 파일을 저장하니 무손실로 데이터를 저장할 수 있었다.)


 소스코드(paperbak.h)

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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                          THIS SOFTWARE IS FREE!                            //
//                                                                            //
// This program is free software; you can redistribute it and/or modify it    //
// under the terms of the GNU General Public License as published by the Free //
// Software Foundation; either version 2 of the License, or (at your option)  //
// any later version. This program is distributed in the hope that it will be //
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of     //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General  //
// Public License (http://www.fsf.org/copyleft/gpl.html) for more details.    //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
 
#include "BZLIB\bzlib.h"
 
////////////////////////////////////////////////////////////////////////////////
///////////////////////////// GENERAL DEFINITIONS //////////////////////////////
 
#ifdef MAINPROG
  #define unique                       // Define MAINPROG in single C unit!
#else
  #define unique extern
#endif
 
#define VERSIONHI      1               // Major version
#define VERSIONLO      10              // Minor version
 
#define MAINDX         800             // Max width of the main window, pixels
#define MAINDY         600             // Max height of the main window, pixels
 
#define TEXTLEN        256             // Maximal length of strings
#define PASSLEN        33              // Maximal length of password, incl. 0
 
#define AESKEYLEN      24              // AES key length in bytes (16, 24, or 32)
 
typedef unsigned char  uchar;
typedef unsigned short ushort;
typedef unsigned int   uint;
typedef unsigned long  ulong;
 
unique HINSTANCE hinst;                // Application's instance
unique HWND      hwmain;               // Handle of the main window
 
 
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////// DATA PROPERTIES ////////////////////////////////
 
// Don't change the definitions below! Program may crash if any modified!
#define NDOT           32              // Block X and Y size, dots
#define NDATA          90              // Number of data bytes in a block
#define MAXSIZE        0x0FFFFF80      // Maximal (theoretical) length of file
#define SUPERBLOCK     0xFFFFFFFF      // Address of superblock
 
#define NGROUP         5               // For NGROUP blocks (1..15), 1 recovery
#define NGROUPMIN      2
#define NGROUPMAX      10
 
typedef struct t_data {                // Block on paper
  ulong          addr;                 // Offset of the block or special code
  uchar          data[NDATA];          // Useful data
  ushort         crc;                  // Cyclic redundancy of addr and data
  uchar          ecc[32];              // Reed-Solomon's error correction code
} t_data;
 
#if sizeof(t_data)!=128
  #error t_data: Invalid data alignment
#endif
 
#define PBM_COMPRESSED 0x01            // Paper backup is compressed
#define PBM_ENCRYPTED  0x02            // Paper backup is encrypted
 
typedef struct t_superdata {           // Identification block on paper
  ulong          addr;                 // Expecting SUPERBLOCK
  ulong          datasize;             // Size of (compressed) data
  ulong          pagesize;             // Size of (compressed) data on page
  ulong          origsize;             // Size of original (uncompressed) data
  uchar          mode;                 // Special mode bits, set of PBM_xxx
  uchar          attributes;           // Basic file attributes
  ushort         page;                 // Actual page (1-based)
  FILETIME       modified;             // Time of last file modification
  ushort         filecrc;              // CRC of compressed decrypted file
  char           name[64];             // File name - may have all 64 chars
  ushort         crc;                  // Cyclic redundancy of previous fields
  uchar          ecc[32];              // Reed-Solomon's error correction code
} t_superdata;
 
#if sizeof(t_superdata)!=sizeof(t_data)
  #error t_superdata: Invalid data alignment
#endif
 
typedef struct t_block {               // Block in memory
  ulong          addr;                 // Offset of the block
  ulong          recsize;              // 0 for data, or length of covered data
  uchar          data[NDATA];          // Useful data
} t_block;
 
typedef struct t_superblock {          // Identification block in memory
  ulong          addr;                 // Expecting SUPERBLOCK
  ulong          datasize;             // Size of (compressed) data
  ulong          pagesize;             // Size of (compressed) data on page
  ulong          origsize;             // Size of original (uncompressed) data
  ulong          mode;                 // Special mode bits, set of PBM_xxx
  ushort         page;                 // Actual page (1-based)
  FILETIME       modified;             // Time of last file modification
  ulong          attributes;           // Basic file attributes
  ulong          filecrc;              // 16-bit CRC of decrypted packed file
  char           name[64];             // File name - may have all 64 chars
  int            ngroup;               // Actual NGROUP on the page
} t_superblock;
 
 
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// CRC //////////////////////////////////////
 
ushort Crc16(uchar *data,int length);
 
 
////////////////////////////////////////////////////////////////////////////////
////////////////////////// REED-SOLOMON ECC ROUTINES ///////////////////////////
 
void   Encode8(uchar *data,uchar *parity,int pad);
int    Decode8(uchar *data, int *eras_pos, int no_eras,int pad);
 
 
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// PRINTER ////////////////////////////////////
 
#define PACKLEN        65536           // Length of data read buffer 64 K
 
typedef struct t_printdata {           // Print control structure
  int            step;                 // Next data printing step (0 - idle)
  char           infile[MAXPATH];      // Name of input file
  char           outbmp[MAXPATH];      // Name of output bitmap (empty: paper)
  HANDLE         hfile;                // Handle of input file
  FILETIME       modified;             // Time of last file modification
  ulong          attributes;           // File attributes
  ulong          origsize;             // Original file size, bytes
  ulong          readsize;             // Amount of data read from file so far
  ulong          datasize;             // Size of (compressed) data
  ulong          alignedsize;          // Data size aligned to next 16 bytes
  ulong          pagesize;             // Size of (compressed) data on page
  int            compression;          // 0: none, 1: fast, 2: maximal
  int            encryption;           // 0: none, 1: encrypt
  int            printheader;          // Print header and footer
  int            printborder;          // Print border around bitmap
  int            redundancy;           // Redundancy
  uchar          *buf;                 // Buffer for compressed file
  ulong          bufsize;              // Size of buf, bytes
  uchar          *readbuf;             // Read buffer, PACKLEN bytes long
  bz_stream      bzstream;             // Compression control structure
  int            bufcrc;               // 16-bit CRC of (packed) data in buf
  t_superdata    superdata;            // Identification block on paper
  HDC            dc;                   // Printer device context
  int            frompage;             // First page to print (0-based)
  int            topage;               // Last page (0-based, inclusive)
  int            ppix;                 // Printer X resolution, pixels per inch
  int            ppiy;                 // Printer Y resolution, pixels per inch
  int            width;                // Page width, pixels
  int            height;               // Page height, pixels
  HFONT          hfont6;               // Font 1/6 inch high
  HFONT          hfont10;              // Font 1/10 inch high
  int            extratop;             // Height of title line, pixels
  int            extrabottom;          // Height of info line, pixels
  int            black;                // Palette index of dots colour
  int            borderleft;           // Left page border, pixels
  int            borderright;          // Right page border, pixels
  int            bordertop;            // Top page border, pixels
  int            borderbottom;         // Bottom page border, pixels
  int            dx,dy;                // Distance between dots, pixels
  int            px,py;                // Dot size, pixels
  int            nx,ny;                // Grid dimensions, blocks
  int            border;               // Border around the data grid, pixels
  HBITMAP        hbmp;                 // Handle of memory bitmap
  uchar          *dibbits;             // Pointer to DIB bits
  uchar          *drawbits;            // Pointer to file bitmap bits
  uchar          bmi[sizeof(BITMAPINFO)+256*sizeof(RGBQUAD)]; // Bitmap info
  int            startdoc;             // Print job started
} t_printdata;
 
 
unique PAGESETUPDLG pagesetup;         // Structure with printer page settings
unique int       resx,resy;            // Printer resolution, dpi (may be 0!)
unique t_printdata printdata;          // Print control structure
 
void   Initializeprintsettings(void);
void   Closeprintsettings(void);
void   Setuppage(void);
void   Stopprinting(t_printdata *print);
void   Nextdataprintingstep(t_printdata *print);
void   Printfile(char *path,char *bmp);
 
 
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// DECODER ////////////////////////////////////
 
#define M_BEST         0x00000001      // Search for best possible quality
 
typedef struct t_procdata {            // Descriptor of processed data
  int            step;                 // Next data processing step (0 - idle)
  int            mode;                 // Set of M_xxx
  uchar          *data;                // Pointer to bitmap
  int            sizex;                // X bitmap size, pixels
  int            sizey;                // Y bitmap size, pixels
  int            gridxmin,gridxmax;    // Rought X grid limits, pixels
  int            gridymin,gridymax;    // Rought Y grid limits, pixels
  int            searchx0,searchx1;    // X grid search limits, pixels
  int            searchy0,searchy1;    // Y grid search limits, pixels
  int            cmean;                // Mean grid intensity (0..255)
  int            cmin,cmax;            // Minimal and maximal grid intensity
  float          sharpfactor;          // Estimated sharpness correction factor
  float          xpeak;                // Base X grid line, pixels
  float          xstep;                // X grid step, pixels
  float          xangle;               // X tilt, radians
  float          ypeak;                // Base Y grid line, pixels
  float          ystep;                // Y grid step, pixels
  float          yangle;               // Y tilt, radians
  float          blockborder;          // Relative width of border around block
  int            bufdx,bufdy;          // Dimensions of block buffers, pixels
  uchar          *buf1,*buf2;          // Rotated and sharpened block
  int            *bufx,*bufy;          // Block grid data finders
  uchar          *unsharp;             // Either buf1 or buf2
  uchar          *sharp;               // Either buf1 or buf2
  float          blockxpeak,blockypeak;// Exact block position in unsharp
  float          blockxstep,blockystep;// Exact block dimensions in unsharp
  int            nposx;                // Number of blocks to scan in X
  int            nposy;                // Number of blocks to scan in X
  int            posx,posy;            // Next block to scan
  t_data         uncorrected;          // Data before ECC for block display
  t_block        *blocklist;           // List of blocks recognized on page
  t_superblock   superblock;           // Page header
  int            maxdotsize;           // Maximal size of the data dot, pixels
  int            orientation;          // Data orientation (-1: unknown)
  int            ngood;                // Page statistics: good blocks
  int            nbad;                 // Page statistics: bad blocks
  int            nsuper;               // Page statistics: good superblocks
  int            nrestored;            // Page statistics: restored bytes
} t_procdata;
 
unique int       orientation;          // Orientation of bitmap (-1: unknown)
unique t_procdata procdata;            // Descriptor of processed data
 
void   Nextdataprocessingstep(t_procdata *pdata);
void   Freeprocdata(t_procdata *pdata);
void   Startbitmapdecoding(t_procdata *pdata,uchar *data,int sizex,int sizey);
void   Stopbitmapdecoding(t_procdata *pdata);
int    Decodeblock(t_procdata *pdata,int posx,int posy,t_data *result);
 
 
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// FILE PROCESSOR ////////////////////////////////
 
#define NFILE          5               // Max number of simultaneous files
 
typedef struct t_fproc {               // Descriptor of processed file
  int            busy;                 // In work
  // General file data.
  char           name[64];             // File name - may have all 64 chars
  FILETIME       modified;             // Time of last file modification
  ulong          attributes;           // Basic file attrributes
  ulong          datasize;             // Size of (compressed) data
  ulong          pagesize;             // Size of (compressed) data on page
  ulong          origsize;             // Size of original (uncompressed) data
  ulong          mode;                 // Special mode bits, set of PBM_xxx
  int            npages;               // Total number of pages
  ulong          filecrc;              // 16-bit CRC of decrypted packed file
  // Properties of currently processed page.
  int            page;                 // Currently processed page
  int            ngroup;               // Actual NGROUP on the page
  ulong          minpageaddr;          // Minimal address of block on page
  ulong          maxpageaddr;          // Maximal address of block on page
  // Gathered data.
  int            nblock;               // Total number of data blocks
  int            ndata;                // Number of decoded blocks so far
  uchar          *datavalid;           // 0:data invalid, 1:valid, 2:recovery
  uchar          *data;                // Gathered data
  // Statistics.
  int            goodblocks;           // Total number of good blocks read
  int            badblocks;            // Total number of unreadable blocks
  ulong          restoredbytes;        // Total number of bytes restored by ECC
  int            recoveredblocks;      // Total number of recovered blocks
  int            rempages[8];          // 1-based list of remaining pages
} t_fproc;
 
unique t_fproc   fproc[NFILE];         // Processed files
 
void   Closefproc(int slot);
int    Startnextpage(t_superblock *superblock);
int    Addblock(t_block *block,int slot);
int    Finishpage(int slot,int ngood,int nbad,ulong nrestored);
int    Saverestoredfile(int slot,int force);
 
 
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// SCANNER ////////////////////////////////////
 
unique int       twainstate;           // According to TWAIN specifications
 
int    Decodebitmap(char *path);
int    SelectTWAINsource(void);
int    OpenTWAINmanager(void);
int    OpenTWAINinterface(void);
int    CloseTWAINmanager(void);
int    PassmessagetoTWAIN(MSG *msg);
int    LoadTWAINlibrary(void);
void   CloseTWAINlibrary(void);
 
 
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// CONTROLS ///////////////////////////////////
 
#define MAINCLASS      "P2DMAIN"       // Name of the class of main window
#define DATAFRAMECLASS "P2DATAFRAME"   // Name of the class of data frame
#define DISPLAYCLASS   "P2DDISPL"      // Name of the class of display window
#define PROGRESSCLASS  "P2DPROGRESS"   // Name of the class of progress window
#define BUTTONFRAME    "P2BTNFRAME"    // Name of the class of button frame
#define INFOFRAMECLASS "P2INFOFRAME"   // Name of the class of info frame
#define INFOBTNCLASS   "P2INFOBTNS"    // Name of the class of info btn holder
#define BLOCKSELCLASS  "P2BLOCKSEL"    // Name of the class of block selector
 
#define DELTA          3               // Distance between panels in main window
#define BUTTONDY       32              // Height of the buttons
 
// Display modes.
#define DISP_QUALITY   0               // Display quality map
#define DISP_BLOCK     1               // Display block image
 
unique HBRUSH    graybrush;            // Button face brush (usually gray)
 
void   Reporterror(char *text);
void   Message(char *text,int percent);
 
void   Updatebuttons(void);
void   Setdisplaymode(int mode);
void   Initqualitymap(int nx,int ny);
void   Addblocktomap(int x,int y,int nrestored);
void   Displayblockimage(t_procdata *pdata,int posx,int posy,
         int answer,t_data *result);
int    Changeblockselection(WPARAM wp);
void   Updatefileinfo(int slot,t_fproc *fproc);
int    Createcontrols(void);
 
 
////////////////////////////////////////////////////////////////////////////////
////////////////////////////// SERVICE FUNCTIONS ///////////////////////////////
 
int    Filetimetotext(FILETIME *fttime,char *s,int n);
int    Selectinfile(void);                     
int    Selectoutfile(char defname[64]);
int    Selectinbmp(void);
int    Selectoutbmp(void);
 
void   Clearqueue(void);
int    Getqueuefreecount(void);
int    Addfiletoqueue(char *path,int isbitmap);
int    Getfilefromqueue(char *path);
 
 
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// USER INTERFACE ////////////////////////////////
 
unique char      infile[MAXPATH];      // Last selected file to read
unique char      outbmp[MAXPATH];      // Last selected bitmap to save
unique char      inbmp[MAXPATH];       // Last selected bitmap to read
unique char      outfile[MAXPATH];     // Last selected data file to save
 
unique char      password[PASSLEN];    // Encryption password
 
unique int       dpi;                  // Dot raster, dots per inch
unique int       dotpercent;           // Dot size, percent of dpi
unique int       compression;          // 0: none, 1: fast, 2: maximal
unique int       redundancy;           // Redundancy (NGROUPMIN..NGROUPMAX)
unique int       printheader;          // Print header and footer
unique int       printborder;          // Border around bitmap
unique int       autosave;             // Autosave completed files
unique int       bestquality;          // Determine best quality
unique int       encryption;           // Encrypt data before printing
unique int       opentext;             // Enter passwords in open text
 
unique int       marginunits;          // 0:undef, 1:inches, 2:millimeters
unique int       marginleft;           // Left printer page margin
unique int       marginright;          // Right printer page margin
unique int       margintop;            // Top printer page margin
unique int       marginbottom;         // Bottom printer page margin
 
void   Options(void);
int    Confirmpassword();
int    Getpassword(void);
 
 
cs


 소스를 본다면, bzip의 압축을 이용하고(해당 압축 코드는 나중에 시간이 되면, 하도록 하겠다.)


1
2
3
4
5
6
7
8
9
10
11
12
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// CRC //////////////////////////////////////
 
ushort Crc16(uchar *data,int length);
 
 
////////////////////////////////////////////////////////////////////////////////
////////////////////////// REED-SOLOMON ECC ROUTINES ///////////////////////////
 
void   Encode8(uchar *data,uchar *parity,int pad);
int    Decode8(uchar *data, int *eras_pos, int no_eras,int pad);
 
cs


 CRC-16과 ECC를 위한 함수 선언으로, 해당 값은 간단하게 말하자면, 파일의 오류 여부를 확인 하기 위한 함수 소스이다.

 오류가 있다면, 해당 오류를 분석해서 오류를 개선하거나 제거하는 용도로 사용할 수 있게 된다.

 

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
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// PRINTER ////////////////////////////////////
 
#define PACKLEN        65536           // Length of data read buffer 64 K
 
typedef struct t_printdata {           // Print control structure
  int            step;                 // Next data printing step (0 - idle)
  char           infile[MAXPATH];      // Name of input file
  char           outbmp[MAXPATH];      // Name of output bitmap (empty: paper)
  HANDLE         hfile;                // Handle of input file
  FILETIME       modified;             // Time of last file modification
  ulong          attributes;           // File attributes
  ulong          origsize;             // Original file size, bytes
  ulong          readsize;             // Amount of data read from file so far
  ulong          datasize;             // Size of (compressed) data
  ulong          alignedsize;          // Data size aligned to next 16 bytes
  ulong          pagesize;             // Size of (compressed) data on page
  int            compression;          // 0: none, 1: fast, 2: maximal
  int            encryption;           // 0: none, 1: encrypt
  int            printheader;          // Print header and footer
  int            printborder;          // Print border around bitmap
  int            redundancy;           // Redundancy
  uchar          *buf;                 // Buffer for compressed file
  ulong          bufsize;              // Size of buf, bytes
  uchar          *readbuf;             // Read buffer, PACKLEN bytes long
  bz_stream      bzstream;             // Compression control structure
  int            bufcrc;               // 16-bit CRC of (packed) data in buf
  t_superdata    superdata;            // Identification block on paper
  HDC            dc;                   // Printer device context
  int            frompage;             // First page to print (0-based)
  int            topage;               // Last page (0-based, inclusive)
  int            ppix;                 // Printer X resolution, pixels per inch
  int            ppiy;                 // Printer Y resolution, pixels per inch
  int            width;                // Page width, pixels
  int            height;               // Page height, pixels
  HFONT          hfont6;               // Font 1/6 inch high
  HFONT          hfont10;              // Font 1/10 inch high
  int            extratop;             // Height of title line, pixels
  int            extrabottom;          // Height of info line, pixels
  int            black;                // Palette index of dots colour
  int            borderleft;           // Left page border, pixels
  int            borderright;          // Right page border, pixels
  int            bordertop;            // Top page border, pixels
  int            borderbottom;         // Bottom page border, pixels
  int            dx,dy;                // Distance between dots, pixels
  int            px,py;                // Dot size, pixels
  int            nx,ny;                // Grid dimensions, blocks
  int            border;               // Border around the data grid, pixels
  HBITMAP        hbmp;                 // Handle of memory bitmap
  uchar          *dibbits;             // Pointer to DIB bits
  uchar          *drawbits;            // Pointer to file bitmap bits
  uchar          bmi[sizeof(BITMAPINFO)+256*sizeof(RGBQUAD)]; // Bitmap info
  int            startdoc;             // Print job started
} t_printdata;
 
 
unique PAGESETUPDLG pagesetup;         // Structure with printer page settings
unique int       resx,resy;            // Printer resolution, dpi (may be 0!)
unique t_printdata printdata;          // Print control structure
 
void   Initializeprintsettings(void);
void   Closeprintsettings(void);
void   Setuppage(void);
void   Stopprinting(t_printdata *print);
void   Nextdataprintingstep(t_printdata *print);
void   Printfile(char *path,char *bmp);
 
 
cs



 여기서 프린터에 대해서 설정하는 것이다.

 간단하게, Dot Matrix로 저장하기 위한 것으로 printer.cpp에 사용하기 위한 구조체와 함수 선언이다.


 함수 선언에서는 printer setting의 설정과, printing하기 위한 세팅 및 처리이다.


 

1
2
3
4
5
6
7
8
9
10
11
12
13
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// SCANNER ////////////////////////////////////
 
unique int       twainstate;           // According to TWAIN specifications
 
int    Decodebitmap(char *path);
int    SelectTWAINsource(void);
int    OpenTWAINmanager(void);
int    OpenTWAINinterface(void);
int    CloseTWAINmanager(void);
int    PassmessagetoTWAIN(MSG *msg);
int    LoadTWAINlibrary(void);
void   CloseTWAINlibrary(void);
cs


 Scanner라고해서, Bitmap으로 저장되어 있는 Dot Matrix와 외부 Scanner에 대해서 연결해서 사용할 수 있는 TWAIN 라이브러리를 연결해서 사용한다.


 ※ TWAIN란, 외부 스캐너를 컨트롤을 하기 위해서 윈도우나 리눅스에서 지원해주는 드라이버이다.


 이 드라이버를 이용해서 외부 스캐너에 연결되어 컨트롤을 할 수 있게 된다.


 보기만해도 알 수 있듯. Scanner는 기본적으로 TWAIN을 위한 함수 선언들이 대부분이다.


 Bitmap에 대해서 컨트롤하는 용도로 Decodebitmap이라는 것을 이용한다.


 이 함수를 이용하면, 도움이 될 것이다.


 여기서 TWAIN은 외부 스캐너에 연동되서 스캔을 하는 것이기 때문에, TWAIN는 다른 용도로 쓸 수도 있다.


 

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
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// DECODER ////////////////////////////////////
 
#define M_BEST         0x00000001      // Search for best possible quality
 
typedef struct t_procdata {            // Descriptor of processed data
  int            step;                 // Next data processing step (0 - idle)
  int            mode;                 // Set of M_xxx
  uchar          *data;                // Pointer to bitmap
  int            sizex;                // X bitmap size, pixels
  int            sizey;                // Y bitmap size, pixels
  int            gridxmin,gridxmax;    // Rought X grid limits, pixels
  int            gridymin,gridymax;    // Rought Y grid limits, pixels
  int            searchx0,searchx1;    // X grid search limits, pixels
  int            searchy0,searchy1;    // Y grid search limits, pixels
  int            cmean;                // Mean grid intensity (0..255)
  int            cmin,cmax;            // Minimal and maximal grid intensity
  float          sharpfactor;          // Estimated sharpness correction factor
  float          xpeak;                // Base X grid line, pixels
  float          xstep;                // X grid step, pixels
  float          xangle;               // X tilt, radians
  float          ypeak;                // Base Y grid line, pixels
  float          ystep;                // Y grid step, pixels
  float          yangle;               // Y tilt, radians
  float          blockborder;          // Relative width of border around block
  int            bufdx,bufdy;          // Dimensions of block buffers, pixels
  uchar          *buf1,*buf2;          // Rotated and sharpened block
  int            *bufx,*bufy;          // Block grid data finders
  uchar          *unsharp;             // Either buf1 or buf2
  uchar          *sharp;               // Either buf1 or buf2
  float          blockxpeak,blockypeak;// Exact block position in unsharp
  float          blockxstep,blockystep;// Exact block dimensions in unsharp
  int            nposx;                // Number of blocks to scan in X
  int            nposy;                // Number of blocks to scan in X
  int            posx,posy;            // Next block to scan
  t_data         uncorrected;          // Data before ECC for block display
  t_block        *blocklist;           // List of blocks recognized on page
  t_superblock   superblock;           // Page header
  int            maxdotsize;           // Maximal size of the data dot, pixels
  int            orientation;          // Data orientation (-1: unknown)
  int            ngood;                // Page statistics: good blocks
  int            nbad;                 // Page statistics: bad blocks
  int            nsuper;               // Page statistics: good superblocks
  int            nrestored;            // Page statistics: restored bytes
} t_procdata;
 
unique int       orientation;          // Orientation of bitmap (-1: unknown)
unique t_procdata procdata;            // Descriptor of processed data
 
void   Nextdataprocessingstep(t_procdata *pdata);
void   Freeprocdata(t_procdata *pdata);
void   Startbitmapdecoding(t_procdata *pdata,uchar *data,int sizex,int sizey);
void   Stopbitmapdecoding(t_procdata *pdata);
int    Decodeblock(t_procdata *pdata,int posx,int posy,t_data *result);
cs

 

 Decoder라는 곳에서 페이지의 디코딩을 할때, 사용하는 구조체 및 함수들이다.


 나머지 선언들은, Win32등을 이용해서, Windows창을 띄우기 위해 선언하는 구조체와 함수들로 보인다.


 User Interface에 대해서는 조금더 찾아봐야 될 것 같긴하지만, 이것은 딱히 필요는 하지 않아 보인다.

Posted by JunkMam
,
 7-zip을 이용해서 사용하는 것으로 암호를 걸 수 있다.(tar나 wim등 암호를 지원해주지 않는 포맷도 존재한다.)

 암호를 걸어서 사용자가 해당 패스워드를 사용하기 위해서 다음과 같은 명령어를 이용한다.

 -p(password)

 예을 들어서 7z a -tzip -scsUTF-8 -mx9 -bsp1 -pMyPassword Test.zip Test

 이렇게 하면, MyPassword라는 형태의 암호를 사용해서 패스워드를 가지게 만들어 놓게 된다.

 암호를 풀떄도 -p을 사용하면, 패스워드를 풀 수 있다.
 여기서 scsUTF-8은 파일 경로를 UTF-8로 설정해서 저장한다는 뜻이다.
 mx9는 압축률을 0~9로 나눠서 가장 높은 압축률을 사용하도록 설정한 것이다.


 7z x -aoa bsp1 -pMyPassword Test.zip


 이렇게 하면, aoa로 덮어씌우면서 암호화된 압축 파일을 풀 수 있다.

Posted by JunkMam
,
 파일들이 많이 있어서 반복적인일을 많이하게 되었다.(많은 프로그램을 관리하게 되었다.)

 그래서, 프로그램을 만들거나, 관리하는 것을 해야되는데.


 프로그램을 일일히 만들기 귀찮아서, powershell을 이용해서 프로그램을 관리하도록 할려고 CD-Rom의 Eject(CD-Rom 열기)와 Close(CD-Rom 닫기)를 이용해야되었다.


 그래서 다음과 같은 소스를 찾게 되었다.


 원 링크 : https://gallery.technet.microsoft.com/scriptcenter/EjectClose-CDDVD-drive-56d39361


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
<
     .SYNOPSIS 
        This script helps in ejecting or closing the CD/DVD Drive 
    .DESCRIPTION 
        This script helps in ejecting or closing the CD/DVD Drive 
    .PARAMETER  Eject 
        Ejects the CD/DVD Drive 
    .PARAMETER  Close 
        Closes the CD/DVD Drive 
    .EXAMPLE 
        C:\PS>c:\Scripts\Set-CDDriveState -Eject 
         
        Ejects the CD Drive 
    .EXAMPLE 
        C:\PS>c:\Scripts\Set-CDDriveState -Eject 
         
        Closes the CD Drive 
    .Notes 
        Author : Sitaram Pamarthi 
        WebSite: http://techibee.com 
 
#> 
[CmdletBinding()] 
param( 
[switch]$Eject, 
[switch]$Close 
try { 
    $Diskmaster = New-Object -ComObject IMAPI2.MsftDiscMaster2 
    $DiskRecorder = New-Object -ComObject IMAPI2.MsftDiscRecorder2 
    $DiskRecorder.InitializeDiscRecorder($DiskMaster) 
    if ($Eject) { 
        $DiskRecorder.EjectMedia() 
    } elseif($Close) { 
        $DiskRecorder.CloseTray() 
    } 
} catch { 
    Write-Error "Failed to operate the disk. Details : $_" 
 
cs


 이렇게 하면, DiskRecorder에서 EjectMedia을 사용하면, Media를 열기 위해서 동작한다.


 반대로, CloseTray을 사용한다면, 이상없이 닫히게 된다.


 이것을 이용해서 CD을 열고 닫으면서 관리하는 매크로를 만들 수 있게 된다.

'연습' 카테고리의 다른 글

paperbak source 분석해보기 -paperbak.h-  (0) 2017.01.05
7z Command Line 암호 걸기  (0) 2017.01.04
7z 사용법 -압축방법-  (0) 2017.01.02
CD-Rom eject(CD롬 열기 소스) 소스  (0) 2017.01.01
최신 코덱인 AV1 현황.  (0) 2016.12.24
Posted by JunkMam
,
 7z등 압축 프로그램을 사용해야되는 일이 생겼다.

 그래서 7zip을 사용하는 방법을 여기에 기록할려고 한다.

  7z을 설치하는 방법은 GUI와 그냥 7z-command, source build 등 다양한 방법이 있으다.(Windows에서는 GUI가 대부분이다.)

 GUI방식은 다음과 같다.

 http://www.7-zip.org/download.html에 들어가서 7zip을 다운 받는다.

 Download 7-zip에서 .exe과 .msi는 설치 프로그램으로 만들어진 파일들이다.

 



 여기서 7-zip for 32-bit혹은 64-bit에 맞춰서 설치하면, 실행이 된다.(OS가 64-bit인데, 32-bit 파일을 받아도 상관없으나. OS가 32-bit인데, 64-bit 파일을 받아서 사용하는 것은 문제가 되니 주의해서 다운 받길 바란다.)


 여기서 압축을 풀면 알아서 설치가 되는걸 알 수 있다.


 소스빌더는 방법이 다양해서 넘기도록 하겠다.(컴파일로 차근차근 컴파일해나가야 된다.)


 command 방식으로 압축할때는 다음과 같은 방법을 사용한다.


 7z a num.7z num


 여기서 7z의 명령어에서 a는 압축을 한다는 뜻으로 쓰인다.


 7z에서는 zip과 7z등을 지원해주는데, 이것을 압축 타입이라고 한다.


 -tzip 혹은 -t7z -tgzip 등을 이용하면, 다양한 종류로 압축이 된다. 만약, 이게 없다면, 기본적으로 파일의 확장자에 따라서 결정이 된다.


 압축을 풀때는 다음과 같이 사용한다.


 7z x num.7z


 여기서


 7z e num.7z을 사용할 경우. 디렉토리 상관 없이 파일이 풀리게 된다.(경로를 상관 없이 풀리게 된다.) 그래서 이름이 중복이 되는 경우에는 문제가 발생한다.


 7z x num.7z을 사용하면 경로에 맞춰서 파일이 풀리니 이것을 이용하면 된다.


 -scs가 있다. 이것은 파일 경로의 문자열을 뭘로 할 것인지 정하는 것이다.


 UTF-8으로 할것인지. 혹은 UTF-16등으로 저장할 것인지 나와있다.


 왠만해선 UTF-8로 저장하는게 유동성이 있을 것으로 보인다.

 


 

'연습' 카테고리의 다른 글

7z Command Line 암호 걸기  (0) 2017.01.04
PowerShell CD Eject/Close 설정하는 방법.  (0) 2017.01.03
CD-Rom eject(CD롬 열기 소스) 소스  (0) 2017.01.01
최신 코덱인 AV1 현황.  (0) 2016.12.24
powershell 비프음 발생시키기.  (0) 2016.11.15
Posted by JunkMam
,


 참조 링크 : http://forums.codeguru.com/showthread.php?263490-C-Source-For-Ejecting-CD-ROM


 설정하는 참조 링크에 존재하는 소스


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
#include <windows.h>
#include <winioctl.h>
#include <stdio.h>
 
#define LOCK_TIMEOUT  10000       // 10 Seconds
#define LOCK_RETRIES  20
 
HANDLE OpenVolume(TCHAR cDriveLetter)
{
    HANDLE hVolume;
    UINT   uDriveType;
    char   szVolumeName[8];
    char   szRootName[5];
    DWORD  dwAccessFlags;
   
    sprintf(szRootName, "%c:\\", cDriveLetter);
 
    uDriveType = GetDriveType(szRootName);
    switch(uDriveType) {
      case DRIVE_REMOVABLE:
           dwAccessFlags = GENERIC_READ | GENERIC_WRITE;
           break;
      case DRIVE_CDROM:
           dwAccessFlags = GENERIC_READ;
           break;
      default:
           printf("Cannot eject.  Drive type is incorrect.\n");
           return INVALID_HANDLE_VALUE;
    }
 
    sprintf(szVolumeName, "\\\\.\\%c:", cDriveLetter);
 
    hVolume = CreateFile( szVolumeName,
                          dwAccessFlags,
                          FILE_SHARE_READ | FILE_SHARE_WRITE,
                          NULL,
                          OPEN_EXISTING,
                          0,
                          NULL );
 
    if (hVolume == INVALID_HANDLE_VALUE)
      printf("CreateFile error %d\n", GetLastError());
    return hVolume;
}
 
BOOL CloseVolume(HANDLE hVolume)
{
    return CloseHandle(hVolume);
}
 
BOOL LockVolume(HANDLE hVolume)
{
    DWORD dwBytesReturned;
    DWORD dwSleepAmount;
    int nTryCount;
 
    dwSleepAmount = LOCK_TIMEOUT / LOCK_RETRIES;
 
    // Do this in a loop until a timeout period has expired
    for (nTryCount = 0; nTryCount < LOCK_RETRIES; nTryCount++) {
      if (DeviceIoControl(hVolume,
                          FSCTL_LOCK_VOLUME,
                          NULL0,
                          NULL0,
                          &dwBytesReturned,
                          NULL))
         return TRUE;
 
      Sleep(dwSleepAmount);
    }
    return FALSE;
}
 
BOOL DismountVolume(HANDLE hVolume)
{
    DWORD dwBytesReturned;
 
    return DeviceIoControl( hVolume,
                            FSCTL_DISMOUNT_VOLUME,
                            NULL0,
                            NULL0,
                            &dwBytesReturned,
                            NULL);
}
 
BOOL PreventRemovalOfVolume(HANDLE hVolume, BOOL fPreventRemoval)
{
    DWORD dwBytesReturned;
    PREVENT_MEDIA_REMOVAL PMRBuffer;
 
    PMRBuffer.PreventMediaRemoval = fPreventRemoval;
 
    return DeviceIoControl( hVolume,
                            IOCTL_STORAGE_MEDIA_REMOVAL,
                            &PMRBuffer, sizeof(PREVENT_MEDIA_REMOVAL),
                            NULL0,
                            &dwBytesReturned,
                            NULL);
}
 
AutoEjectVolume(HANDLE hVolume)
{
    DWORD dwBytesReturned;
 
    return DeviceIoControl( hVolume,
                            IOCTL_STORAGE_EJECT_MEDIA,
                            NULL0,
                            NULL0,
                            &dwBytesReturned,
                            NULL);
}
 
BOOL EjectVolume(TCHAR cDriveLetter)
{
    HANDLE hVolume;
 
    BOOL fRemoveSafely = FALSE;
    BOOL fAutoEject = FALSE;
 
    hVolume = OpenVolume(cDriveLetter);
    if (hVolume == INVALID_HANDLE_VALUE)
      return FALSE;
 
    // Lock and dismount the volume.
    if (LockVolume(hVolume) && DismountVolume(hVolume)) {
      fRemoveSafely = TRUE;
      // Set prevent removal to false and eject the volume.
      if (PreventRemovalOfVolume(hVolume, FALSE) && AutoEjectVolume(hVolume))
        fAutoEject = TRUE;
    }
 
    // Close the volume so other processes can use the drive.
    if (!CloseVolume(hVolume))
      return FALSE;
 
    if (fAutoEject)
      printf("Media in Drive %c has been ejected safely.\n", cDriveLetter);
    else {
      if (fRemoveSafely)
        printf("Media in Drive %c can be safely removed.\n", cDriveLetter);
    }
    return TRUE;
}
 
void Usage()
{
    printf("Usage: Eject <drive letter>\n\n");
    return ;
}
 
void main(int argc, char * argv[])
{
    if (argc != 2) {
      Usage();
      return ;
    }
 
    if (!EjectVolume(argv[1][0]))
      printf("Failure ejecting drive %c.\n", argv[1][0]);
 
    return ;
}
cs


'연습' 카테고리의 다른 글

PowerShell CD Eject/Close 설정하는 방법.  (0) 2017.01.03
7z 사용법 -압축방법-  (0) 2017.01.02
최신 코덱인 AV1 현황.  (0) 2016.12.24
powershell 비프음 발생시키기.  (0) 2016.11.15
구글 드라이브 검색 사용법  (0) 2016.11.14
Posted by JunkMam
,