2010년 2월 12일 금요일

File Down 받기

Client로 파일을 다운 받는다.

 

ASP(VB)

 

<!-- METADATA TYPE="typelib" FILE="C:\program Files\Common Files\System\ado\msado15.dll" -->

 

      Dim objFile, filename

      filename = "text.txt"

 

      Set objFile = Server.CreateObject("ADODB.Recordset") '결과 레코드셋 생성 '

      Response.contentType = "application/unknown"

      Response.AddHeader "Content-Disposition", "attachment; filename=" & filename

      Response.CacheControl = "public"

      Response.Write("확인") ' 파일에 쓰기

      Response.Write(" " & vbcrlf) ' Enter 입력

      set objFile = Nothing

 

파일 다운로드 또는 Open 창을 띄워 Client가 Down 받을수 있도록 한다.

출처 : Tong - 공원님의 ┣ ★ 먹고사는일(Web)통

CreateTextFile 을 이용한 File 처리

Web에서는 Client로 파일이 저장되는 것을 기본적으로 금지하고 있다.

 

그래서 Server 에서 파일을 생성하여 그 파일을 다시 Client로 다운 받는 방식을 사용하는데

 

CreateTextFile을 이용하여 파일을 생성하는 것을 알아본다.

 

CreateTextFile는 FileSystemObject 객체에 정의되어 있다.

 

CreateTextFile는 파일을 생성하여 저장한다.

 

사용 방법 (ASP_vb)

 

      Dim fileObj, fileCon

      Dim filename filename = server.MapPath("/testfile1.txt")

      Set fileObj = CreateObject("Scripting.FileSystemObject")

      Set fileCon = fileObj.CreateTextFile(filename, true) ' 줄을 씁니다.

 

      if fileObj.fileExists(filename) Then        ' 파일 생성여부 확인

           fileCon.Write ("테스트") ' 파일을 닫습니다.

           fileCon.WriteBlankLines ("테스트") ' 파일을 닫습니다.

           fileCon.WriteLine ("테스트") ' 파일을 닫습니다.

           fileCon.Close

      else

           '생성실패

      end if

 

CreateTextFile("파일 이름", "덥어쓰기 여부", "Unicode여부:기본 ASCII")

mapPath : server의 Web 서비스 위치

Write : File에 쓴다.

WriteBlankLines : Line을 띄운다.

WriteLine : File에 한 라인을 쓴다.

 

2010년 2월 10일 수요일

TCHAR => char* 유니코드

유니코드 일때

 

TCHAR szFileName[MAX_PATH];

 

/// 길이

int nLengs = (wcslen(szFileName)+1)*2;

 

char* chrTemp[MAX_PATH];

 

WideCharToMultiByte(CP_ACP, 0, szFileName, -1, (LPSTR)chrTemp, nLengs, NULL, NULL);

 

**** 출처

http://angelgrd.egloos.com/2142788 

2010년 1월 29일 금요일

GetSysColor(int nValue)

정말 잘 잊어 버리는 System color

출처 : msdn

 

Value Meaning

COLOR_3DDKSHADOW
21

Dark shadow for three-dimensional display elements.

COLOR_3DFACE
15

Face color for three-dimensional display elements and for dialog box backgrounds.

COLOR_3DHIGHLIGHT
20

Highlight color for three-dimensional display elements (for edges facing the light source.)

COLOR_3DHILIGHT
20

Highlight color for three-dimensional display elements (for edges facing the light source.)

COLOR_3DLIGHT
22

Light color for three-dimensional display elements (for edges facing the light source.)

COLOR_3DSHADOW
16

Shadow color for three-dimensional display elements (for edges facing away from the light source).

COLOR_ACTIVEBORDER
10

Active window border.

COLOR_ACTIVECAPTION
2

Active window title bar.

Specifies the left side color in the color gradient of an active window's title bar if the gradient effect is enabled.

COLOR_APPWORKSPACE
12

Background color of multiple document interface (MDI) applications.

COLOR_BACKGROUND
1

Desktop.

COLOR_BTNFACE
15

Face color for three-dimensional display elements and for dialog box backgrounds.

COLOR_BTNHIGHLIGHT
20

Highlight color for three-dimensional display elements (for edges facing the light source.)

COLOR_BTNHILIGHT
20

Highlight color for three-dimensional display elements (for edges facing the light source.)

COLOR_BTNSHADOW
16

Shadow color for three-dimensional display elements (for edges facing away from the light source).

COLOR_BTNTEXT
18

Text on push buttons.

COLOR_CAPTIONTEXT
9

Text in caption, size box, and scroll bar arrow box.

COLOR_DESKTOP
1

Desktop.

COLOR_GRADIENTACTIVECAPTION
27

Right side color in the color gradient of an active window's title bar. COLOR_ACTIVECAPTION specifies the left side color. Use SPI_GETGRADIENTCAPTIONS with the SystemParametersInfo function to determine whether the gradient effect is enabled.

COLOR_GRADIENTINACTIVECAPTION
28

Right side color in the color gradient of an inactive window's title bar. COLOR_INACTIVECAPTION specifies the left side color.

COLOR_GRAYTEXT
17

Grayed (disabled) text. This color is set to 0 if the current display driver does not support a solid gray color.

COLOR_HIGHLIGHT
13

Item(s) selected in a control.

COLOR_HIGHLIGHTTEXT
14

Text of item(s) selected in a control.

COLOR_HOTLIGHT
26

Color for a hyperlink or hot-tracked item.

COLOR_INACTIVEBORDER
11

Inactive window border.

COLOR_INACTIVECAPTION
3

Inactive window caption.

Specifies the left side color in the color gradient of an inactive window's title bar if the gradient effect is enabled.

COLOR_INACTIVECAPTIONTEXT
19

Color of text in an inactive caption.

COLOR_INFOBK
24

Background color for tooltip controls.

COLOR_INFOTEXT
23

Text color for tooltip controls.

COLOR_MENU
4

Menu background.

COLOR_MENUHILIGHT
29

The color used to highlight menu items when the menu appears as a flat menu (see SystemParametersInfo). The highlighted menu item is outlined with COLOR_HIGHLIGHT.

Windows 2000:  This value is not supported.

COLOR_MENUBAR
30

The background color for the menu bar when menus appear as flat menus (see SystemParametersInfo). However, COLOR_MENU continues to specify the background color of the menu popup.

Windows 2000:  This value is not supported.

COLOR_MENUTEXT
7

Text in menus.

COLOR_SCROLLBAR
0

Scroll bar gray area.

COLOR_WINDOW
5

Window background.

COLOR_WINDOWFRAME
6

Window frame.

COLOR_WINDOWTEXT
8

Text in windows.

OnMouseLeave() 메시지 발생

OnMouseHover(UINT nFlags, CPoint point)

OnMouseLeave()

 

OnMouseMove(UINT nFlags, CPoint point) 함수에 TRACKMOUSEEVENT를 이용하여  Mouse Hover, Leave 등록하고 주기적으로 마우스의 위치를 확인 전달 한다.

 


void CUserClass::OnMouseMove(UINT nFlags, CPoint point)
{
 TRACKMOUSEEVENT tmev;
 tmev.cbSize = sizeof(tmev);
 tmev.hwndTrack = m_hWnd;
 tmev.dwFlags = TME_LEAVE|TME_HOVER;
 tmev.dwHoverTime = 1;
 TrackMouseEvent(&tmev);
 CButton::OnMouseMove(nFlags, point);
}

2009년 12월 23일 수요일

CD-ROM 외장하드 USB 메모리 자동실행 방지

목적 :  CD ROM 외장하드 USB 메모리 자동실행 방지 하게 하여서 바이러스및 스파이웨어 접근성을 적게 한다.

 

시작->제어판->관리도구->서비스

ShellHWDetection (Shell Hardware Detection)  : 자동 재생 하드웨어 이벤트에 대해 알림을 제공합니다.

 

을 사용 안 함 으로 바꾸고 재부팅한다.

 

http://frank.nextios.com/entry/CD-ROM-외장하드-USB-메모리-자동실행-방지

2009년 10월 30일 금요일

GDIpluse 사용 Image 저장

#include <gdiplus.h>

 

 "image/bmp",
 "image/jpeg",
 "image/png",
 "image/gif"

 

using namespace Gdiplus;

 

saveImage

{

CLSID pngClsid;
 GetFormatClsid("image/jpeg", &pngClsid);

 

 HPALETTE hpal;

///팔레트 설정
 hpal = (HPALETTE)GetStockObject(DEFAULT_PALETTE);
 Bitmap bitmap(hbitmap,hpal);

 

/// image 저장

Gdiplus::Status status = bitmap.Save(path, &pngClsid, NULL);

}

 

/// 저장 데이터의 format 설정

int GetFormatClsid(const WCHAR* format, CLSID* pClsid)

{

UINT  unImageNumber = 0;
 UINT  unImageSize = 0; 

 ImageCodecInfo* pImageCodecInfo = NULL;

/// Image 크기
 GetImageEncodersSize(&unImageNumber, &unImageSize);
 if(unImageSize == 0)
  return -1;

/// Image 속성

 pImageCodecInfo = (ImageCodecInfo*)(malloc(unImageSize));
 if(pImageCodecInfo == NULL)
  return -1;

 GetImageEncoders(unImageNumber, unImageSize, pImageCodecInfo);

 for(UINT uCount = 0; uCount < unImageNumber; ++uCount)
 {
  if( wcscmp(pImageCodecInfo[uCount].MimeType, format) == 0 )
  {
   *pClsid = pImageCodecInfo[uCount].Clsid;
   free(pImageCodecInfo);
   return uCount;
  }   
 }

 free(pImageCodecInfo);
 return -1;

 

}