VC++6에는 F4/Shift+F4로 찾기 결과창에서 앞뒤로 이동하였는데,

VS2013에서는 F8로 되고,

F4는 Properties 창이 띄우기에 불편하여

손에 익숙하고 이동이 빠른 F4 로 변경하는 방법:


아래 그림의 것을 서로 바꾸어 설정한다.


F4 / Shift+F4


F8/Shift+F8




Posted by 세모아
,

COPYDATASTRUCT 의

cbData에 숫자를, lpData에 문자열만 넣어서 

간단한 자료만 송수신 하는 예제 코드




송신부 (C#)

        public struct COPYDATASTRUCT

        {

            public IntPtr dwData;

            public int cbData;

            [MarshalAs(UnmanagedType.LPStr)]

            public string lpData;

        }


        private void OnButtonSendClick(object sender, EventArgs e)

        {

            string msg = this.tbMsg.Text.Trim();


            if (string.IsNullOrEmpty(msg))

            {

                MessageBox.Show("메세지를 입력해주세요");

                return;

            }


            IntPtr hwndRcvr = FindWindow(null, "CppReceiveWM_COPYDATA"); //"LHJ WINDOW");

//                byte[] buff = System.Text.Encoding.Default.GetBytes(msg);


                COPYDATASTRUCT cds = new COPYDATASTRUCT();

                cds.dwData = IntPtr.Zero;

//                cds.cbData = buff.Length + 1; //+1을 빼면 수신측에서 cds.lpdata의 뒤에 이상한 글자 붙음.

                cds.cbData = msg.Length+1; //+1을 빼면 수신측에서 cds.lpdata의 뒤에 이상한 글자 붙음.

                cds.lpData = msg;


                SendMessage(hwndRcvr, WM_COPYDATA, 0, ref cds);

        }





수신부 (C++)

 : memcpy_s(.) 을 없애서 빠른 응답속도를 지원토록 함


typedef struct tagCOPYDATASTRUCT2 {
    ULONG_PTR dwData;
    DWORD cbData;
     PVOID lpData;
} COPYDATASTRUCT2, *PCOPYDATASTRUCT2;


INT_PTR CALLBACK DialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

{

//LHJ version //15.3.28 ---------------

    switch (message)

    {

case WM_COPYDATA:        

HandleWMCOPYDATA(hWnd, wParam, lParam);

break;

    default:

return DefWindowProc(hWnd, message, wParam, lParam);

    }

    return 0;

}


bool HandleWMCOPYDATA(HWND hWnd, WPARAM wParam, LPARAM lParam)

{

PCOPYDATASTRUCT2 pcds;

pcds = (PCOPYDATASTRUCT2)lParam;

try 

{

    // If the size matches

int nsize = pcds->cbData;

{

        SetDlgItemInt(hWnd, IDC_NUMBER_STATIC, nsize, TRUE);

//   std::wstring s1 = (LPCWSTR)pcds->lpData; //송신부가  [MarshalAs(UnmanagedType.LPStr)] 이므로 LPCWSTR은 에러


std::string s2 = (LPSTR)pcds->lpData;

std::wstring s1;

s1.assign(s2.begin(), s2.end());  


// SetDlgItemTextW(hWnd, IDC_MESSAGE_STATIC, (LPCWSTR)pcds->lpData); // >image);

SetDlgItemText(hWnd, IDC_MESSAGE_STATIC, s1.c_str()); // >image);




// The receiving application should consider the data (pcds->lpData) 

        // read-only. The pcds parameter is valid only during the processing 

        // of the message. The receiving application should not free the 

        // memory referenced by pcds. If the receiving application must 

        // access the data after SendMessage returns, it must copy the data 

        // into a local buffer. 

//        memcpy_s(&myStruct, sizeof(myStruct), pcds->lpData, pcds->cbData);

//        memcpy_s(&myStruct, nsize, pcds->lpData, pcds->cbData);


        // Display the MY_STRUCT value in the window.

        // Display the MY_STRUCT value in the window.

//        SetDlgItemInt(hWnd, IDC_NUMBER_STATIC, myStruct.Number, TRUE);

//        SetDlgItemText(hWnd, IDC_MESSAGE_STATIC, myStruct.Message);


//wchar_t text1[50000];

//mbstowcs(text1, myStruct.Message, strlen(myStruct.Message) + 1);

//        SetDlgItemText(hWnd, IDC_MESSAGE_STATIC, text1);


//        SetDlgItemInt(hWnd, IDC_NUMBER_STATIC, pMyStruct->Number, TRUE);

// LPCTSTR s2;

// s2 = (LPCTSTR) pMyStruct->Message;

//        SetDlgItemText(hWnd, IDC_MESSAGE_STATIC, s2);

    }

}

catch( int)

{

//MessageBox(hWnd, L"1", L"2", MB_OK);

}

return true;

}



Posted by 세모아
,


출처 : http://myblue0324.tistory.com/118


  1. // 방법1.  
  2. std::string str = "string";  
  3. std::wstring wstr = L"";  
  4.   
  5. wstr.assign(str.begin(), str.end());  
  6.   
  7. // 방법2.   
  8. USES_CONVERSION;  
  9.   
  10. std::string str = "string";  
  11. std::wstring wstr(A2W(str.c_str()));  


2. std::wstring을 std::string으로 변환.

  1. // 방법1.  
  2. std::wstring wstr = L"string";  
  3. std::string str = "";  
  4.   
  5. str.assign(wstr.begin(), wstr.end());  
  6.   
  7. // 방법2.  
  8. USES_UTF8_CONVERSION;  
  9.   
  10. std::wstring wstr = L"string";  
  11. str::string str(W2A(wstr.c_str()));  


위의 문자열을 CString형으로 변환하고자 할 경우에는 간단하게 아래와 같이 변경이 가능합니다.

  1. #ifdef _UNICODE  
  2.     std::wstring s = L"string";  
  3.     CString str(s.c_str());   
  4. #else  
  5.     std::string s = "string";  
  6.     CString str(s.c_str());   
  7. #endif  


Posted by 세모아
,

My 정리 :


std::string s2 = (LPSTR)pcds->lpData;


To "convert" a std::string to a LPCSTR depends on the exact context but usually calling .c_str() is sufficient.

This works.

void TakesString(LPCSTR param);

void f(const std::string& param)
{
    TakesString(param.c_str());
}

Note that you shouldn't attempt to do something like this.

LPCSTR GetString()
{
    std::string tmp("temporary");
    return tmp.c_str();
}

The buffer returned by .c_str() is owned by the std::string instance and will only be valid until the string is next modified or destroyed.



정의 -----------------------

LPSTR - (long) pointer to string - char *

LPCSTR - (long) pointer to constant string - const char *

LPWSTR - (long) pointer to Unicode (wide) string - wchar_t *

LPCWSTR - (long) pointer to constant Unicode (wide) string - const wchar_t *

LPTSTR - (long) pointer to TCHAR (Unicode if UNICODE is defined, ANSI if not) string - TCHAR *

LPCTSTR - (long) pointer to constant TCHAR string - const TCHAR *



std:string 정의 페이지

http://www.cplusplus.com/reference/string/string/



원본 페이지 :



from: http://stackoverflow.com/questions/1200188/how-to-convert-stdstring-to-lpcstr


How can I convert a std::string to LPCSTR? Also, how can I convert a std::string to LPWSTR?

I am totally confused with these LPCSTR LPSTR LPWSTR LPCWSTR?

Are LPWSTR and LPCWSTR are the same?

shareimprove this question

str.c_str() gives you a const char *, which is an LPCSTR (Long Pointer to Constant STRing) -- means that it's a pointer to a 0 terminated string of characters. W means wide string (composed of wchar_t instead of char).

shareimprove this answer
4 
Minor picky point: on x64 LPCSTR would be a 64-bit pointer to a (constant) null-terminated string. –  Joel Jul 30 '09 at 14:41
1 
the C in LPCSTR stand for const not C –  mathk Jan 30 '13 at 9:14

Call c_str() to get a const char * (LPCSTR) from a std::string.

It's all in the name:

LPSTR - (long) pointer to string - char *

LPCSTR - (long) pointer to constant string - const char *

LPWSTR - (long) pointer to Unicode (wide) string - wchar_t *

LPCWSTR - (long) pointer to constant Unicode (wide) string - const wchar_t *

LPTSTR - (long) pointer to TCHAR (Unicode if UNICODE is defined, ANSI if not) string - TCHAR *

LPCTSTR - (long) pointer to constant TCHAR string - const TCHAR *

You can ignore the L (long) part of the names -- it's a holdover from 16-bit Windows.

shareimprove this answer
3 
+1 Make it very easy. –  Sauron Jul 29 '09 at 13:24
   
Thank u very Much for ur support –  Cute Jul 29 '09 at 13:39

These are Microsoft defined typedefs which correspond to:

LPCSTR: pointer to null terminated const string of char

LPSTR: pointer to null terminated char string of char (often a buffer is passed and used as an 'output' param)

LPCWSTR: pointer to null terminated string of const wchar_t

LPWSTR: pointer to null terminated string of wchar_t (often a buffer is passed and used as an 'output' param)

To "convert" a std::string to a LPCSTR depends on the exact context but usually calling .c_str() is sufficient.

This works.

void TakesString(LPCSTR param);

void f(const std::string& param)
{
    TakesString(param.c_str());
}

Note that you shouldn't attempt to do something like this.

LPCSTR GetString()
{
    std::string tmp("temporary");
    return tmp.c_str();
}

The buffer returned by .c_str() is owned by the std::string instance and will only be valid until the string is next modified or destroyed.

To convert a std::string to a LPWSTR is more complicated. Wanting an LPWSTR implies that you need a modifiable buffer and you also need to be sure that you understand what character encodingthe std::string is using. If the std::string contains a string using the system default encoding (assuming windows, here), then you can find the length of the required wide character buffer and perform the transcoding using MultiByteToWideChar (a Win32 API function).

e.g.

void f(const std:string& instr)
{
    // Assumes std::string is encoded in the current Windows ANSI codepage
    int bufferlen = ::MultiByteToWideChar(CP_ACP, 0, instr.c_str(), instr.size(), NULL, 0);

    if (bufferlen == 0)
    {
        // Something went wrong. Perhaps, check GetLastError() and log.
        return;
    }

    // Allocate new LPWSTR - must deallocate it later
    LPWSTR widestr = new WCHAR[bufferlen + 1];

    ::MultiByteToWideChar(CP_ACP, 0, instr.c_str(), instr.size(), widestr, bufferlen);

    // Ensure wide string is null terminated
    widestr[bufferlen] = 0;

    // Do something with widestr

    delete[] widestr;
}
shareimprove this answer
   
How to Convert std::String to LPWSTR ??? –  Cute Jul 29 '09 at 13:44
   
Scholar and a gentleman! –  Russbear Aug 2 '11 at 22:02

Using LPWSTR you could change contents of string where it points to. Using LPCWSTR you couldn't change contents of string where it points to.

std::string s = SOME_STRING;
// get temporary LPSTR (not really safe)
LPSTR pst = &s[0];
// get temporary LPCSTR (pretty safe)
LPCSTR pcstr = s.c_str();
// convert to std::wstring
std::wstring ws; 
ws.assign( s.begin(), s.end() );
// get temporary LPWSTR (not really safe)
LPWSTR pwst = &ws[0];
// get temporary LPCWSTR (pretty safe)
LPCWSTR pcwstr = ws.c_str();

LPWSTR is just a pointer to original string. You shouldn't return it from function using the sample above. To get not temporary LPWSTR you should made a copy of original string on the heap. Check the sample below:

LPWSTR ConvertToLPWSTR( const std::string& s )
{
  LPWSTR ws = new wchar_t[s.size()+1]; // +1 for zero at the end
  copy( s.begin(), s.end(), ws );
  ws[s.size()] = 0; // zero at the end
  return ws;
}

void f()
{
  std::string s = SOME_STRING;
  LPWSTR ws = ConvertToLPWSTR( s );

  // some actions

  delete[] ws; // caller responsible for deletion
}
shareimprove this answer

The MultiByteToWideChar answer that Charles Bailey gave is the correct one. Because LPCWSTR is just a typedef for const WCHAR*widestr in the example code there can be used wherever a LPWSTR is expected or where a LPCWSTR is expected.

One minor tweak would be to use std::vector<WCHAR> instead of a manually managed array:

// using vector, buffer is deallocated when function ends
std::vector<WCHAR> widestr(bufferlen + 1);

::MultiByteToWideChar(CP_ACP, 0, instr.c_str(), instr.size(), &widestr[0], bufferlen);

// Ensure wide string is null terminated
widestr[bufferlen] = 0;

// no need to delete; handled by vector

Also, if you need to work with wide strings to start with, you can use std::wstring instead of std::string. If you want to work with the Windows TCHAR type, you can use std::basic_string<TCHAR>. Converting from std::wstring to LPCWSTR or from std::basic_string<TCHAR> to LPCTSTR is just a matter of calling c_str. It's when you're changing between ANSI and UTF-16 characters that MultiByteToWideChar (and its inverse WideCharToMultiByte) comes into the picture.

shareimprove this answer

The conversion is simple:

std::string str; LPCSTR lpcstr = str.c_str();

shareimprove this answer

Converting is simple:

std::string myString;

LPCSTR lpMyString = myString.c_str();

One thing to be careful of here is that c_str does not return a copy of myString, but just a pointer to the character string that std::string wraps. If you want/need a copy you'll need to make one yourself using strcpy.

shareimprove this answer
   
How to Convert std::String to LPWSTR ??? –  Cute Jul 29 '09 at 13:44

The easiest way to convert a std::string to a LPWSTR is in my opinion:

  1. Convert the std::string to a std::vector<wchar_t>
  2. Take the address of the first wchar_t in the vector.

std::vector<wchar_t> has a templated ctor which will take two iterators, such as the std::string.begin() and .end() iterators. This will convert each char to a wchar_t, though. That's only valid if the std::string contains ASCII or Latin-1, due to the way Unicode values resemble Latin-1 values. If it contains CP1252 or characters from any other encoding, it's more complicated. You'll then need to convert the characters.


Posted by 세모아
,

출처: http://gap85.tistory.com/140


C#, 크로스 스레드 작업이 잘못되었습니다.

방법: 스레드로부터 안전한 방식으로 Windows Forms 컨트롤 호출(참조: http://msdn.microsoft.com/ko-kr/library/ms171728.aspx)

InvalidOperationException
크로스 스레드 작업이 잘못되었습니다. 'textBox1' 컨트롤이 자신이 만들어진 스레드가 아닌 스레드에서 액세스되었습니다.

다른 스레드에서 컨트롤에 접근하려 할 때, 예외가 발생한다.
이 예외는 릴리즈 모드에서는 나타나지 않고, 디버그 모드에서만 나타난다고 한다.
이 예외를 무시하거나, Invoke하는 방법으로 크로스 스레드 작업을 가능하게 할 수 있다.

무시하는 방법은 아래 코드를 삽입하면 된다.

1
CheckForIllegalCrossThreadCalls = false;



출처 : http://itmbox.blogspot.kr/2012/07/c.html

Posted by 세모아
,

출처 : http://cafe.naver.com/cccculb/148


Delegate(대리자)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

장에서는 5장에서 언급한 대리자(Delegate) 대해서 보다 심도 깊게 다루게 것입니다. Delegate 메서드의 기능을 대신해 주는 대리자라고 배웠습니다. 메서드를 보다 효율적으로 사용하기 위하여 메서드 자체를 캡슐화하는 기능입니다. 그래서, 메서드를 대신하는 대리자를 호출하면 메서드를 직접 호출하지 않고도 메서드를 호출할 있습니다.

 

중요 !! 대리자(Delegate)

메서드의 대리자(Delegate)

 메서드를 보다 효율적으로 사용하기 위하여 특정 메서드 자체를 캡슐화할 있게 만들어 주는 방법

 

Delegate 주는 장점은 메서드 자체를 캡슐화하기 때문에 메서드를 보다 효율적으로 사용할 있게 해준다는 것입니다. 메서드를 어떻게 Delegate 하는지에 대해서 알아보겠습니다.

 

1단계 Delegate 메서드를 정한다.

여러분이 Delegate 만들기 위해서는 제일 먼저, Delegate 메서드를 정해야 합니다. Delegate 메서드를 정한다는 것은 어떠한 메서드가 대리자를 통해서 호출될 것인지의 문제입니다. Delegate 메서드는 다음과 같습니다.

 

Delegate 메서드 정하기

using System;

class 
AType{
  
public void F1() { //Delegate
 메서드 1
    
System.Console.WriteLine("AType.F1"
);
  }
  
public void F2(int x){ //Delegate
 메서드 2
    
System.Console.WriteLine("AType.F2 x=" 
+ x);
  }
}

12-1 Delegate 메서드 선택

 

void F1() void F2(int x) 메서드를 Delegate 것입니다. 메서드의 형태가 다르기 때문에 각각 Delegate 다르게 만들어 주어야 합니다. , 대리자 2개를 만들어야 하는 것입니다. Delegate 사용할 메서드가 정해졌다면 Delegate 선언해야 합니다. 다음은 Delegate 선언하는 방법입니다.

 

2단계 메서드에 맞는 Delegate 선언하기

Delegate 선언하려면 일단 메서드의 시그너쳐(Signature) 정확하게 일치시켜야 합니다. 그래서, 아래와 같이 Delegate 메서드의 리턴타입과 매개변수를 정확하게 일치시키고 있는 것입니다.

 

Delegate 선언하기

using System;

delegate void SimpleDelegate1(); 

//Delegate 선언 1  void F1()
delegate void SimpleDelegate2(int i); 

//Delegate 선언 2 void F2()

class 
AType{
  
public void 
F1() {
    System.Console.WriteLine(
"AType.F1"
);
  }
  
public void F2(int 
x){
    System.Console.WriteLine(
"AType.F2 x=" 
+ x);
  }
}

12-2 Delegate 선언하기

 

메서드의 시그너쳐

여러분은 메서드 오버로딩을 공부할 오버로딩 메서드를 만드는 방법에 대해서 배웠습니다. 오버로딩 메서드를 만드는 방법은 메서드의 시그너쳐(Signature) 다르게 해주어야 합니다. , 메서드의 매개변수와 매개변수의 데이터타입을 다르게 해주어야 하는 것입니다. 오버로딩에서는 메서드의 반환형은 시그너쳐로 이용되지 않지만 Delegate에서는 반환형도 시그너쳐에 포함됩니다.

 이름은 상관없지만 Delegate 선언할 메서드의 시그너쳐와 Delegate 시그너쳐는 반드시 일치시켜야 합니다.

 

3단계 임의의 객체 만들기

Delegate 메서드를 정하고 Delegate 선언했다면 이제 메서드가 포함된 클래스의 객체를 만들어야 합니다. 그래야 특정 객체의 메서드가 하나의 독립적인 Delegate로서 활동할 있습니다

Delegate 메서드를 포함한 클래스의 객체만들기

using System;

delegate void 
SimpleDelegate1();
delegate 
void SimpleDelegate2(int 
i);

class 
AType{
  
public void 
F1() {
    System.Console.WriteLine(
"AType.F1"
);
  }
  
public void F2(int 
x){
    System.Console.WriteLine(
"AType.F2 x=" 
+ x);
  }
//class

class 
DeleTest {
  
public static void 
Main(){
    AType atype = 
new AType(); //
객체 생성
  
}
//class

12-3 임의의 객체 생성

 위와 같이 F1() F2() 메서드가 포함된 AType 클래스의 객체 atype 선언했습니다. 다음은 atype 객체의 메서드를 실제 Delegate 만드는 작업을 하셔야 합니다.

 

4단계 Delegate 생성과 호출

마지막으로 Delegate 생성하여 해당 Delegate 호출해 주면 됩니다. 일반 메서드를 호출하듯이 간단하게 Delegate 이용하여 메서드를 호출할 있습니다.

 

&

DeleTest.cs

Ü Delegate 전체구현

using System;

delegate void 
SimpleDelegate1();
delegate 
void SimpleDelegate2(int 
i);

class 
AType{
  
public void 
F1() {
    System.Console.WriteLine(
"AType.F1"
);
  }
  
public void F2(int 
x){
    System.Console.WriteLine(
"AType.F2 x=" 
+ x);
  }
//class

class 
DeleTest {
  
public static void 
Main(){
    AType atype = 
new 
AType();
    SimpleDelegate1 s1 = 
new SimpleDelegate1(atype.F1); //Delegate 
생성
    
SimpleDelegate2 s2 = new SimpleDelegate2(atype.F2); //Delegate 
생성
    
s1(); //Delegate
 이용한 호출 1
    
s2(1000); //Delegate
 이용한 호출 2
  
//main
//class

C:\C#Example\12>csc DeleTest.cs

C:\C#Example\12>DeleTest

AType.F1

AType.F2 x=1000

 

Delegate 만들 해당 Delegate 매개변수로 메서드의 이름을 넣어 주게 됩니다. 메서드를 매개변수로 넣어 주면 모든 Delegate 만들기 작업은 끝납니다. 그리고, 이제부터는 메서드를 호출할 객체를 이용하는 것이 아니라 대리자를 이용하여 호출이 가능한 것입니다. 물론, 대리자라 할지라도 메서드에 일치하는, 대리자에 맞는 매개변수를 넣어서 대리자를 호출하셔야 합니다.

 

절에서는 대리자(Delegate) 만드는 기본적인 방법에 대하여 알아보았습니다. 다음 절에서는 대리자를 이용한 실제 구현을 알아보도록 하겠습니다.


'Programming' 카테고리의 다른 글

C#, 크로스 스레드 작업이 잘못되었습니다.  (0) 2015.03.19
VC++ 단축키  (0) 2015.03.05
[펌] VC++ : error LNK2026 해결책  (0) 2015.03.05
Posted by 세모아
,

VC++ 단축키

Programming 2015. 3. 5. 20:25


Ctrl-K, C : 선택한 블록을 모두 주석 처리

Ctrl-K, U : 선택한 블록을 모두 주석 처리 해제 

Ctrl-A : 전체 코드 블럭잡기 -> Ctrl-K,F : 선택한 영역 자동 코드 정렬  (이거 다시 찾다가 포스팅하는 중...)


Ctrl-F7 : 현 파일만 컴파일

Shift+Ctrl-F7 : 현 프로젝트만 빌드 <- 내가 직접 설정: Tools -> Options -> Keyboard -  Build.BuildSelection   

VC++ 주석설정 단축키

http://sjw0612.egloos.com/1896680

Ctrl + K +C 
: 영역을 주석처리합니다.  

Ctrl + K + U 
: 영역 주석처리를 해체합니다


Posted by 세모아
,

error LNK2026: module unsafe for SAFESEH image.


구 버전에서 작성된 프로젝트를 신 버전으로 가지고 왔을때 가끔 보이는 에러.


해결방법(현재 사용중인 버전 studio 2012)

project property - Linker - commandLine - 하단의 Additional option 아래 텍스트 박스에 /safeseh:no  삽입

'Programming' 카테고리의 다른 글

VC++ 단축키  (0) 2015.03.05
static link(정적 링크) & dynamic link(동적 링크)  (1) 2015.03.03
책 - Learn Object Pascal with Delphi  (0) 2014.09.30
Posted by 세모아
,

My 요약 : 아래 색칠한 부분 참고



출처: http://sweeper.egloos.com/1792751


Static & Dynamic Library



1. Static library

Dynamic (linking) library (흔히 얘기하는 DLL)을 설명하기 위해 간단하게 정리한다.

특정 기능의 라이브러리를 static 하게 제작한다는 것은 link 단계에서
라이브러리(*.lib 파일)를 실행 바이너리에 포함시킨다는 얘기이다.

즉, 라이브러리의 동작 코드가 이를 사용하는 실행 바이너리 속에 
포함되기 때문에 별도의 추가 작업없이, 그리고 독립적으로(실행 바이너리만으로...)
라이브러리 함수들을 사용할 수 있다.

하지만, 정적 라이브러리를 사용하는 프로그램이 늘어나면 날수록
불필요하게 실행 파일들의 크기가 커지며, 
라이브러리가 동시에 여러 실행 바이너리에 포함되어 실행되는 경우
메인 메모리의 공간 활용 효율이 떨어지는 등 multiple-caller program이 존재하는 경우 그다지 바람직하지 않다.

정적 라이브러리를 사용하기 위해서는 프로젝트 설정의 Link 옵션에 
라이브러리를 추가해 주거나 아래의 #pragma 지시자를 사용하면 된다.

#pragma comment(lib, "NAME.lib")


2. Dynamic (linking) library : DLL

말 그대로 "동적으로 링크하여 사용하는 라이브러리" 이다.

동적 라이브러리는 이를 사용하고자 하는 실행 바이너리에서 
필요시 사용할 수 있도록 최소한의 정보만 포함하여 링크하거나,
아예 독립적으로 DLL을 로드/사용/해제할 수 있다.

1) Implicit linking

DLL을 구현하고 컴파일하고 나면 static library와는 다르게  output file이 2개 생성된다.
하나는 *.lib 파일이고 하나는 *.dll 파일이다.
여기서 *.lib 파일은 static library의 *.lib 파일과는 전혀 다르다.

Static library의 *.lib 파일은 라이브러리 전체 코드를 포함하는 바이너리이며,
DLL의 *.lib 파일은 DLL이 제공하고자 하는 함수 정보(함수명)을 가지는 정보 파일이다.

DLL의 *.lib 파일을 이용하여 링킹하는 것을 암시적 링킹(implicit linking)이라고 한다.
실행 바이너리를 링크 단계에서 실행 바이너리의 *.obj 파일들과 DLL의 *.lib 파일을
함께 링크하여 이 정보를 토대로 runtime에 DLL의 함수 코드를 참조하게 되는 것이다.
(한 줄로 요약하면 *.lib 파일은 링크시 필요하고, *.dll 파일은 실행시 필요하다)

정적 라이브러리를 사용할 때와 같이 프로젝트 설정의 Link 옵션에 
라이브러리를 추가해 주거나 아래의 #pragma 지시자를 사용하면 된다.

#pragma comment(lib, "NAME.lib")

2) Explicit linking

명시적 링킹에서는 *.lib 파일이 필요하지 않다.
실행 바이너리 링크 단계에서 DLL의 함수 정보가 필요하지 않기 때문이다.

명시적 링킹에서 사용되는 세 가지 함수와 역할은 다음과 같다.

1. LoadLibrary : 필요한 DLL을 프로세스 가상 메모리에 맵핑한다.
2. GetProcAddress : DLL 함수의 포인터를 획득한다.
3. FreeLibrary : 프로세스 가상 메모리에서 DLL을 반환한다.

프로세스는 내부적으로 DLL의 레퍼런스 카운트를 계산한다.
LoadLibrary 호출시 DLL의 (프로세스) 레퍼런스 카운트는 1씩 증가하고,
FreeLibrary 호출시 레퍼런스 카운트가 1씩 감소한다. 
레퍼런스 카운트가 0이 될 때 해당 DLL은 프로세스 가상 메모리에서 해제된다.

여기서 주의할 점이 물리 메모리가 아닌 가상 메모리에서의 반환(해제)라는 것이다.
레퍼런스 카운트는 각 프로세스 내부의 호출 회수이지,
전체 프로세스 간의 호출 회수가 아니라는 것이다.

이러한 레퍼런스 카운트를 두는 이유는 프로그램 실행 중에 
DLL을 가상 메모리에 할당, 해제할 수 있도록 하기 위함이다.
(Implicit linking 방식에서는 이러한 장점을 얻을 수 없다.)

정리해서 명시적 링킹의 장점을 세 가지 정도 정리해 보면...

1. DLL이 필요한 시점에서 로딩하고, 불필요해지면 반환하기 때문에 메모리가 절약된다.
2. 프로그램 실행 중에 DLL 교체 및 선택이 가능하다.
3. 암시적 링킹은 프로그램 실행 전에 필요한 모든 DLL을 메모리에 로딩한다.
때문에 실행까지 걸리는 시간이 길어질 수 있다. 반면에 명시적 링킹은 필요한 순간에
하나씩 DLL을 로딩할 수 있기 때문에 그만큼 실행까지 걸리는 시간이 짧고, 
DLL 로딩에 걸리는 시간을 분산시킬 수 있다.

뭐 위와 같이 명확한 장점들이 있음에도 불구하고 암시적 링킹이 더 선호되는 경우가 있는데,
이는 사용하기 쉽기 때문이다. 코드가 간결해 진다는 것, 사용하기 쉽다는 것은
대부분의 경우에 있어서의 성능보다도 더 큰 장점을 지니는 것이 아닌가 생각해 본다.

Posted by 세모아
,

출처: http://lunapiece.net/?mid=Tips&document_srl=4275&page=1



Diff

  1. Select Settings from Explorer's TortoiseSVN submenu.
  2. Switch to the Diff Viewer tab.
  3. Change the radio buttons from TortoiseMerge to External.
  4. In the path edits, enter:
    "C:\Program Files\Beyond Compare 3\BComp.exe" %base %mine /title1=%bname /title2=%yname /leftreadonly

To use Beyond Compare for image comparisons either replace the file C:\Program Files\TortoiseSVN\bin\TortoiseIDiff.exe with a copy of BComp.exe, or click the Advanced button on the Diff Viewer tab and add each image type's extension with the same command line as above.

3-Way Merge (v3 Pro)

  1. Select Settings from Explorer's TortoisSVN submenu.
  2. Switch to the Merge Tool tab.
  3. Change the radio buttons from TortoiseMerge to External.
  4. In the path edits, enter:
    "C:\Program Files\Beyond Compare 3\BComp.exe" %mine %theirs %base %merged /title1=%yname /title2=%tname /title3=%bname /title4=%mname

2-Way Merge (v3 Std, v2)

Use the same steps as above, but use the command line:
"C:\Program Files\Beyond Compare 3\BComp.exe" %mine %theirs /savetarget=%merged


Posted by 세모아
,

모바일 애플리케이션 디버깅 시에 힘든 점 중의 하는 mouse와 touch 이벤트 제어에 관한 것.


이벤트 속도  : click 보다 touch 이벤트가 빠름


컴퓨터 브라우저에서는 touch 이벤트를 인식할 수 없어서 분제 발행

이 분제 해결하려면, javascript 이용해 touch 이벤트를 동일한 mouse 이벤트로 대체.


Touche 이용해서 모든 touch 이벤트를 click 이벤트로 재매핑.

스크립트를 다운로드하여 javascript 안에 추가해주면 됨.

https://github.com/davidcalhoun/touche



Posted by 세모아
,

* minify

http://www.minifyjs.com/javascript-compressor

http://jscompress.com

http://refresh-sf.com/yui


축소된 파일을 원복

http://jsbeautifier.org    : JS Beautifier

'Programming > Web' 카테고리의 다른 글

모바일 앱에서 Touch vs Mouse 이벤트  (0) 2014.11.21
감사합니다 이미지  (0) 2014.02.04
공익웹 아이디어 & Google map api 활용사례  (3) 2012.12.06
Posted by 세모아
,


Android has given a bundle pack for developing phonegap apps here is the link of ADT bundle pack

1) Just download latest ADT-Bundle pack mac or windows 32bit or windows 64bit

2) Download the MDS AppLaud plugin to Eclipse -> Help -> Install New Software to

  https://svn.codespot.com/a/eclipselabs.org/mobile-web-development-with-phonegap/tags/r1.2/download

That's it.


With a single download, the ADT Bundle includes everything you need to begin developing apps:

Eclipse + ADT plugin
Android SDK Tools
Android Platform-tools
The latest Android platform
The latest Android system image for the emulator

I highly recommend Brackets to be used as code editor

share|improve this answer


Posted by 세모아
,

출처: http://netrance.blog.me/110159753435


[Eclipse] Juno 버전 이후 Eclipse Marketplace... 메뉴를 추가하는 방법 Java 기초 / Java

2013/02/14 21:24

복사 http://netrance.blog.me/110159753435

전용뷰어 보기

Juno 버전 이후의 Eclipse에서는 Help - Eclipse Marketplace... 메뉴가 제공되지 않습니다. 이것은 별도로 추가가 가능하며, 방법을 여기에서 정리하고자 합니다.

 

 

Elipse Marketplace... 메뉴를 추가하는 방법

1. 메뉴 Help - Install New Software...를 선택하세요.

 

2. Install 창이 뜬 후 Work with에 아래 주소를 입력하세요.

http://download.eclipse.org/releases/juno

 

3. 2를 실행한 후 창의 중간에 있는 테이블에 여러가지의 체크 항목들이 나타납니다. 그 중에 General Purpose Tools을 열고, 그것의 하위 항목 Marketplace Client를 체크하세요. 그리고 Next  > 버튼을 클릭하세요.

 

4. 잠시 기다리세요.

 

5. Install 창의 중간에 설치할 소프트웨어들이 테이블에 보입니다. Marketplace Client가 있음을 확인하세요. 그 다음에 Next > 버튼을 클릭하시기 바랍니다.

 

6. Review Licenses 단계에서 I accept the terms of the license agreement를 선택하신 후 Finish 버튼을 클릭하세요.

 

7. Marketplace Client 소프트웨어 설치가 시작됩니다. 잠시 기다리면 완료될 것입니다.

 

8. 이클립스는 ADT를 재시작할 것을 요청합니다. Software Updates 창에서 Yes를 클릭해 주세요.

 

 

참고 사이트

http://www.sjava.net/322

 


Posted by 세모아
,




Posted by 세모아
,

집에 있던 부록 CD에서 추출.


database.zip



--------


web.zip

'Programming' 카테고리의 다른 글

책 - Learn Object Pascal with Delphi  (0) 2014.09.30
C++Builder 6 Personal - sn & 설명  (0) 2014.04.11
[펌] manifest 파일이란 무엇인가?  (0) 2013.12.17
Posted by 세모아
,

C++Builder 6 Personal

Serial: e5jr-m926a-25dht
AuthNo: nq5-rag


다운로드:
http://download.borlandforum.com/cbuilder/CBuilder6Personal/CBuilder6Personal.zip


지금부터 C++Builder 6 Personal의 무료 배포 정책을 공식화합니다.
따라서 누구든 무료로 다운받아 자유롭게 사용하실 수 있습니다.

다만, 퍼스널 제품의 라이선스 자체가 구입했든 무료로 다운로드했든 상업적인 용도로 사용할 수 없게 되어 있습니다.
따라서 상업용 애플리케이션을 만들게 되면 라이선스에 저촉됩니다.

Turbo C++Builder 2006 Explorer의 경우, 상업적 목적으로도 합법적으로 무료로 사용하실 수 있습니다.
http://cbuilder.borlandforum.com/impboard/impboard.dll?action=read&db=bcb_res&no=318
(다만 해킹을 통해 제한을 풀면 불법입니다)


---------------------------------------------

C++Builder6 Personal 버전 설치시 추가 설치 패키지.

다운로드:
http://cbuilder.borlandforum.com/impboard/impboard.dll?action=read&db=bcb_res&no=661


Posted by 세모아
,

출처: apple 고객만족도 조사의 마지막 페이지




Posted by 세모아
,

출처:


Manifest 파일은 만들어진 프로그램이 이떤 .Net Framework Assemblies 를 사용하는지 그리고 버젼은 무엇인지 

또 의존성은 어떻게 되는지를 설명 하는 파일이다.

 

프로젝트를 빌드하면 Debug 폴더에 manifest 라는 파일이 생성된다.

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.VC90.DebugMFC" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    </dependentAssembly>
  </dependency>
</assembly>

 

manifest 파일의 내용이다.

XML 형태로 저장 되어 있다.

 

위에 빨간 색으로 기술된 부분이 .net Assemblies 중 어떤 버젼을 사용하고 있는지 debug 인지 release 인지 또 x86 인지 자세히 보여준다.

여기서 주목할 점은 name 과 version 이다.

 

윈도우 폴더 아래에 WinSxS 폴더가 현재 설치 되어 있는 Shared side-by-side assemblies 를 모두 보여준다.

 

실행 후 "this system cannot execute from this program"

 

이라는 에러가 터진다면 manifest 파일을 열고 컴퓨터 WinSxS 폴더를 열어 해당 어셈블리가 있는지 파악한다.

 

만약 존재 하지 않는다면

1. 업데이트 하여 어셈블리 를 자동으로 설치한다.

2. Microsoft Visual C++ Redistribution (재배포) package 를 다운 받아 설치해라

 

visual studio 가 없는 사람들도 프로그램을 돌릴수 있게 된다.

 

그런데 manifest 파일을 만드는 rc 파일이 꼬여 다음과 같은 에러를 내뱉을수 있다.

 

CVTRES : fatal error CVT1100: duplicate resource.  type:MANIFEST, name:1, language:0x0409

fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt

 

먼저 뜻을 보면 rc 파일의 manifest 쪽 이름이 1인 것이 중복되었다고 나온다.

 

찾아가봤다

프로젝트이름.rc -> 우클리-> view code 해서 열어 보면

 

 

1 TEXTINCLUDE DISCARDABLE
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE DISCARDABLE
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE DISCARDABLE
BEGIN
    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
    "#define _AFX_NO_OLE_RESOURCES\r\n"
    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
    "\r\n"
    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
    "#ifdef _WIN32\r\n"
    "LANGUAGE 9, 1\r\n"
    "#pragma code_page(1252)\r\n"
    "#endif //_WIN32\r\n"
    "#include ""afxres.rc""         // Standard components\r\n"
    "#endif\r\n"
    "\0"
END

 

다음과 같은 내용이 나온다.

근데 여기서 1이란 첫번째를 의미 하는것 같은데 이게 중복되었다......

밑에 가보니

 

1                       24      MOVEABLE PURE   "app.manifest"

 

이런 구문이 있다. 뭐지...1 은 정의가 되어있는데 뭘또 정의하고 있지

 

혹시 몰라 다음 구문을 주석 처리했다.

 

뚜둥!! 프로그램이 정상적으로 돌아간다.

 

 

 

Posted by 세모아
,

C++Builder 6 Personal

Serial: e5jr-m926a-25dht
AuthNo: nq5-rag


다운로드:
http://download.borlandforum.com/cbuilder/CBuilder6Personal/CBuilder6Personal.zip


지금부터 C++Builder 6 Personal의 무료 배포 정책을 공식화합니다.
따라서 누구든 무료로 다운받아 자유롭게 사용하실 수 있습니다.

다만, 퍼스널 제품의 라이선스 자체가 구입했든 무료로 다운로드했든 상업적인 용도로 사용할 수 없게 되어 있습니다.
따라서 상업용 애플리케이션을 만들게 되면 라이선스에 저촉됩니다.

Turbo C++Builder 2006 Explorer의 경우, 상업적 목적으로도 합법적으로 무료로 사용하실 수 있습니다.
http://cbuilder.borlandforum.com/impboard/impboard.dll?action=read&db=bcb_res&no=318
(다만 해킹을 통해 제한을 풀면 불법입니다)

Posted by 세모아
,