336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

using System.Diagnostics;



Stopwatch sw = new Stopwatch();


sw.Start();





// TODO






sw.Stop();






MessageBox.Show(sw.ElapsedMilliseconds.ToString() + "ms");



MessageBox.Show(sw.Elapsed.Hour.ToString() + "Minute");

MessageBox.Show(sw.Elapsed.Minute.ToString() + "Minute");

MessageBox.Show(sw.Elapsed.Second.ToString() + "Minute");







Get Audio Device List

Programming/C# 2017. 12. 27. 11:02 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Get Audio Device List




using System.Management;


        public void getAudioDevice()
        {
            ManagementObjectSearcher objSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_SoundDevice");

            ManagementObjectCollection objCollection = objSearcher.Get();

            foreach (ManagementObject obj in objCollection)
            {
                String str = "";
                foreach (PropertyData property in obj.Properties)
                {
                    str += String.Format("{0}:{1}\n", property.Name, property.Value);
                }
                Console.Out.WriteLine(str + "\n\n");
            }
        }





참조 : https://stackoverflow.com/questions/1525320/how-to-enumerate-audio-out-devices-in-c-sharp

CString Tokenize

Programming/C,CPP,CS 2017. 10. 19. 10:25 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

CString Tokenize



문자열을 어떠한 구분자에 의해 나누고 싶을 때

 예를 들어, "6000,A2301BA81301,Sensor1" -> "6000" / "A2301BA81301" / "Sensor1"


1. Tokenize 이용 (.net 함수..6.0에서는 사용을 못 한다.)


CString strFullText = _T("6000,A2301BA81301,Sensor1");

 CString token;

 CString strPortNumber, strName, strSensor;

 int pos = 0;

 int index = 0;


while ((token  = strFullText.Tokenize(_T(","), pos)) != _T(""))

 {

     // 6000

     if(index == 0)

     {

         strPortNumber = token;

         index++;

     }

     // A2301BA81301

     else if(index == 1)

     {

         strName = token;

         index++;

     }

     // Sensor1

     else if(index == 2)

     {

         strSensor = token;

         index++;

     }

 }


2. AfxExtractSubString 이용


CString strFullText = _T("6000,A2301BA81301,Sensor1");

 CString token;

 CString strPortNumber, strName, strSensor;


for( int k=0; k<3; k++ )

 {

     AfxExtractSubString(token, strFullText, k, ',');

     // Port에 정보 넣어준다.

     // 6000

     if(k == 0)

         strPortNumber = token;

     // A2301BA81301

     else if(k == 1)

         strName = token;

     // Sensor1

     else if(k == 2)

         strSensor = token;

 }




출처: http://endlessthirst.tistory.com/418 [세상살이]

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

[CPP] Windows Service 간단하게 만들기

















Service.cpp

Service.h




Service 클래스 추가




stdafx.h 에 필요한 헤더파일 추가



#include <iostream>
#include <conio.h>
#include <WinSvc.h>





main.cpp 에 필요한 내용 추가



// ConsoleApplication5.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.

//

 

#include "stdafx.h"

#include "Service.h"

#include "ConsoleApplication5.h"

 

#ifdef _DEBUG

#define new DEBUG_NEW

#endif

 

 

UINT MTServerThread(LPVOID pParam);

class CUpdateService : public CService{

public:

      CWinThread *_thread;

      void main(void){

            CService::Begin(_T("ConsoleApplication5"));

 

            // TODO : 서비스에서 실행 할 작업을 아래에 작성합니다.

 

            CService::End();

      }

protected:

      void OnStarted(){

            _thread = AfxBeginThread(MTServerThread, 0);

      }

      void OnStopped(){

            DWORD dwExitCode;

            GetExitCodeThread(_thread->m_hThread, &dwExitCode);

            WSACleanup();

      }

};

UINT MTServerThread(LPVOID pParam){

      return 0;

 

}

 

 

// 유일한 응용 프로그램 개체입니다.

 

CWinApp theApp;

 

using namespace std;

 

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])

{

      int nRetCode = 0;

 

      HMODULE hModule = ::GetModuleHandle(NULL);

 

      if (hModule != NULL)

      {

            // MFC를 초기화합니다. 초기화하지 못한 경우 오류를 인쇄합니다.

            if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0))

            {

                  // TODO: 오류 코드를 필요에 따라 수정합니다.

                  _tprintf(_T("심각한 오류: MFC를 초기화하지 못했습니다.\n"));

                  nRetCode = 1;

            }

            else

            {

                  // TODO: 응용 프로그램의 동작은 여기에서 코딩합니다.

                  CUpdateService upServ;

                  if (argc == 2){

                        if (_tcscmp(argv[1], _T("-i")) == 0){

                             upServ.Install(_T("ConsoleApplication5"));

                        }

                        else if (_tcscmp(argv[1], _T("-u")) == 0){

                             upServ.Uninstall(_T("ConsoleApplication5"));

                        }

                        return true;

                  }

                  upServ.main();

            }

      }

      else

      {

            // TODO: 오류 코드를 필요에 따라 수정합니다.

            _tprintf(_T("심각한 오류: GetModuleHandle 실패\n"));

            nRetCode = 1;

      }

 

      return nRetCode;

}

 





'Programming > C,CPP,CS' 카테고리의 다른 글

WAVE form wFormatTag IDs  (0) 2018.04.04
CString Tokenize  (0) 2017.10.19
WaitForMultipleObjects  (0) 2017.04.19
How do I add my domain name to my computers host file?  (0) 2017.04.06
[VS2013] 힙이 손상되었습니다.  (0) 2017.04.05

wave player class

Programming/MFC 2017. 9. 27. 11:14 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

wave player class



1. mciCommand  (적극 권장)

KMedia.h  KMedia.cpp




2. vfw 
KMp3.h  KMp3.cpp




3. directShow 

mp3.h  mp3.cpp


336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

연결 프로그램 변경 [레지스트리 편집]


JSP 파일을 메모장으로 열기 설정을 했습니다..



자.. 그럼 레지스트리를 고쳐볼까요?..

시작 -> 실행.. 을 눌러서 실행창을 띄웁니다..




그리고.. regedit.. 를 입력해서.. 레지스트리 편집기를 띄웁니다..



편집 -> 찾기를 누릅니다.. Ctrl + F 를 누르셔도 됩니다..



찾기에.. 잘 못 연결된 프로그램 파일 형식.. 확장자.. 그러니까 저는 .jsp 파일을 내용에 넣고 찾기를 시작하겠습니다..
문자열 단위로 일치.. 선택하시면.. 정확하게.. .jsp 파일만 찾습니다.. 



여기서 잠깐!.. 
"어랏!?.. 나는 파일 확장자가 안보이는데.. 이게 확장자가 뭐지?".. 하시는 분들도 계실겁니다..



그런 분들은.. 아래 더보기..를 눌러서 보세요..

더보기



아무튼.. 검색으로.. 나오긴 했는데.. 



이건 보기에도.. 너무 깔끔해 보입니다.. (기본값) 밖에는 안보이는군요..
이녀석 지워볼까요?.. 하지만.. 지우기엔 겁이납니다..

F3을 눌러서 다음 .jsp 를 찾던가.. 다시 찾기를 눌러서 .jsp 를 검색합니다..

계속 검색을 하다보니.. 어랏.. 이녀석은 뭔가 있어보입니다.. 특히 OpenWithList 가 눈에 확 들어옵니다..



OpenWithList 를 보니.. 역시.. 메모장이 보이는군요..



a부터 i까지 뭔가 연결되있는것 같습니다.. 연결프로그램을 열어보니.. 여기있는것과 똑같은 것들입니다..



이건 지워도.. 나중에 또.. 추가를 할 수 있으니.. 삭제해버립니다..
여긴.. 제가.. MRUList 는 체크 안했는데.. 같이 지워버리세요..



삭제하고.. 다시 연결 프로그램을 살펴봤는데.. 메모장.. 이녀석은 아직 살아있고..



이녀석도.. 그대로 입니다..



이.. 잡초같은 녀석!.. 이라고 욕하실것 까진 없습니다..

레지스트리 특성상.. 재시작을 해야만.. 변화가 있거든요..

저는 재시작하기는 귀찮고.. 로그오프를 하겠습니다;..

그리고.. 다시 로그인 하는 순간!.. 눈에 보이는 하얀색의 .jsp 파일!..




드디어.. 레지스트리 편집으로.. 연결 프로그램을 초기화하는 방법이 끝났습니다..

이렇게 해서도 연결 프로그램이 바뀌질 않는다면..

UserChoice 란게.. 있을수도 있는데.. 여기서도 값 데이터를.. 삭제해주시면 됩니다..



이렇게 해서도 안바뀌면..
.jsp 검색해서 나온것 중에서.. 값 데이터를.. 지우시고.. 아무것도 없이 넣으시면 됩니다..



위에 OpenWithList 의 기본값중에서 값 데이터를 지워도 상관없지만..
이걸 지우시면.. 알려진 파일 형식이 아니게 되어버려서.. 확장자가 표시가 됩니다..


그럼.. 조심해서 지우시구요.. 지우시기 전에.. 레지스트리 저장을 하시거나.. 어디에 옮겨 적으셔서..
복구를 하실 수 있게.. 조치를 취한 후에.. 하시길 바랍니다..

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

연결 프로그램 변경 [레지스트리 편집]


JSP 파일을 메모장으로 열기 설정을 했습니다..



자.. 그럼 레지스트리를 고쳐볼까요?..

시작 -> 실행.. 을 눌러서 실행창을 띄웁니다..




그리고.. regedit.. 를 입력해서.. 레지스트리 편집기를 띄웁니다..



편집 -> 찾기를 누릅니다.. Ctrl + F 를 누르셔도 됩니다..



찾기에.. 잘 못 연결된 프로그램 파일 형식.. 확장자.. 그러니까 저는 .jsp 파일을 내용에 넣고 찾기를 시작하겠습니다..
문자열 단위로 일치.. 선택하시면.. 정확하게.. .jsp 파일만 찾습니다.. 



여기서 잠깐!.. 
"어랏!?.. 나는 파일 확장자가 안보이는데.. 이게 확장자가 뭐지?".. 하시는 분들도 계실겁니다..



그런 분들은.. 아래 더보기..를 눌러서 보세요..

더보기



아무튼.. 검색으로.. 나오긴 했는데.. 



이건 보기에도.. 너무 깔끔해 보입니다.. (기본값) 밖에는 안보이는군요..
이녀석 지워볼까요?.. 하지만.. 지우기엔 겁이납니다..

F3을 눌러서 다음 .jsp 를 찾던가.. 다시 찾기를 눌러서 .jsp 를 검색합니다..

계속 검색을 하다보니.. 어랏.. 이녀석은 뭔가 있어보입니다.. 특히 OpenWithList 가 눈에 확 들어옵니다..



OpenWithList 를 보니.. 역시.. 메모장이 보이는군요..



a부터 i까지 뭔가 연결되있는것 같습니다.. 연결프로그램을 열어보니.. 여기있는것과 똑같은 것들입니다..



이건 지워도.. 나중에 또.. 추가를 할 수 있으니.. 삭제해버립니다..
여긴.. 제가.. MRUList 는 체크 안했는데.. 같이 지워버리세요..



삭제하고.. 다시 연결 프로그램을 살펴봤는데.. 메모장.. 이녀석은 아직 살아있고..



이녀석도.. 그대로 입니다..



이.. 잡초같은 녀석!.. 이라고 욕하실것 까진 없습니다..

레지스트리 특성상.. 재시작을 해야만.. 변화가 있거든요..

저는 재시작하기는 귀찮고.. 로그오프를 하겠습니다;..

그리고.. 다시 로그인 하는 순간!.. 눈에 보이는 하얀색의 .jsp 파일!..




드디어.. 레지스트리 편집으로.. 연결 프로그램을 초기화하는 방법이 끝났습니다..

이렇게 해서도 연결 프로그램이 바뀌질 않는다면..

UserChoice 란게.. 있을수도 있는데.. 여기서도 값 데이터를.. 삭제해주시면 됩니다..



이렇게 해서도 안바뀌면..
.jsp 검색해서 나온것 중에서.. 값 데이터를.. 지우시고.. 아무것도 없이 넣으시면 됩니다..



위에 OpenWithList 의 기본값중에서 값 데이터를 지워도 상관없지만..
이걸 지우시면.. 알려진 파일 형식이 아니게 되어버려서.. 확장자가 표시가 됩니다..


그럼.. 조심해서 지우시구요.. 지우시기 전에.. 레지스트리 저장을 하시거나.. 어디에 옮겨 적으셔서..
복구를 하실 수 있게.. 조치를 취한 후에.. 하시길 바랍니다..

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

wave player class  (0) 2017.09.27
연결 프로그램 변경 [레지스트리 편집]  (0) 2017.09.27
[MFC] Dialog 닫기 (OnOK/EndDialog)  (0) 2017.02.08
CWnd::Invalidate  (0) 2016.11.15
MFC Dialog Position Save & Load  (0) 2016.11.10

WaitForMultipleObjects

Programming/C,CPP,CS 2017. 4. 19. 09:39 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

WaitForMultipleObjects function


WaitForMultipleObjects는 뜻 그대로 여러개의 object handle이 지정된 상태나 일정 시간이 지날때까지 기다리는 함수이다. 예를들면 복수개의 thread가 모두 종료되기를 기다릴 때 사용할 수 있다. 사용방법은 다음과 같다.



DWORD WINAPI WaitForMultipleObjects( _In_       DWORD  nCount, _In_ const HANDLE *lpHandles, _In_       BOOL   bWaitAll, _In_       DWORD  dwMilliseconds );



  - nCount : lpHandles에 들어있는 object handle의 갯수이다. 최대 MAXIMUM_WAIT_OBJECTS (64개)만을 지정할 수 있다.
  - lpHandles : 함수가 기다릴 object handle의 배열이다. 이 배열은 서로 다른 종류의 obejct의 handle들이 들어갈 수 있다.
  - bWaitAll : TRUE이면 lpHandles의 모든 handle의 signal을 기다리고, TRUE이면 하나라도 signal이 오면 리턴된다. 후자의 경우 리턴값은 signal을 준 object가 된다.
  - dwMilliSeconds : bWaitAll에 의한 조건이 만족되지 않더라도 이 값에 의한 시간이 흐르면 함수는 리턴된다. 0이라면 즉시 리턴되고, INFINITE이면 무한정 기다린다.




WaitForMultipleObjects function

Waits until one or all of the specified objects are in the signaled state or the time-out interval elapses.

To enter an alertable wait state, use the WaitForMultipleObjectsEx function.

Syntax

DWORD WINAPI WaitForMultipleObjects(
  _In_       DWORD  nCount,
  _In_ const HANDLE *lpHandles,
  _In_       BOOL   bWaitAll,
  _In_       DWORD  dwMilliseconds
);

Parameters

nCount [in]

The number of object handles in the array pointed to by lpHandles. The maximum number of object handles is MAXIMUM_WAIT_OBJECTS. This parameter cannot be zero.

lpHandles [in]

An array of object handles. For a list of the object types whose handles can be specified, see the following Remarks section. The array can contain handles to objects of different types. It may not contain multiple copies of the same handle.

If one of these handles is closed while the wait is still pending, the function's behavior is undefined.

The handles must have the SYNCHRONIZE access right. For more information, see Standard Access Rights.

bWaitAll [in]

If this parameter is TRUE, the function returns when the state of all objects in the lpHandles array is signaled. If FALSE, the function returns when the state of any one of the objects is set to signaled. In the latter case, the return value indicates the object whose state caused the function to return.

dwMilliseconds [in]

The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the specified objects are signaled or the interval elapses. If dwMilliseconds is zero, the function does not enter a wait state if the specified objects are not signaled; it always returns immediately. If dwMilliseconds is INFINITE, the function will return only when the specified objects are signaled.

Return value

If the function succeeds, the return value indicates the event that caused the function to return. It can be one of the following values. (Note thatWAIT_OBJECT_0 is defined as 0 and WAIT_ABANDONED_0 is defined as 0x00000080L.)

Return code/valueDescription
WAIT_OBJECT_0 to (WAIT_OBJECT_0 +nCount– 1)

If bWaitAll is TRUE, the return value indicates that the state of all specified objects is signaled.

If bWaitAll is FALSE, the return value minus WAIT_OBJECT_0 indicates the lpHandles array index of the object that satisfied the wait. If more than one object became signaled during the call, this is the array index of the signaled object with the smallest index value of all the signaled objects.

WAIT_ABANDONED_0to (WAIT_ABANDONED_0nCount– 1)

If bWaitAll is TRUE, the return value indicates that the state of all specified objects is signaled and at least one of the objects is an abandoned mutex object.

If bWaitAll is FALSE, the return value minus WAIT_ABANDONED_0 indicates the lpHandles array index of an abandoned mutex object that satisfied the wait. Ownership of the mutex object is granted to the calling thread, and the mutex is set to nonsignaled.

If a mutex was protecting persistent state information, you should check it for consistency.

WAIT_TIMEOUT
0x00000102L

The time-out interval elapsed and the conditions specified by the bWaitAll parameter are not satisfied.

WAIT_FAILED
(DWORD)0xFFFFFFFF

The function has failed. To get extended error information, call GetLastError.

 



336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
How do I add my domain name to my computers host file?
Posted by Support, Last modified by Support on 12 September 2013 01:44 PM

Windows

    • Open Notepad and then open the "Hosts" file on your computer. The location of the "Hosts" file is as follows:

      Windows 95/98/Me:  c:\windows\hosts 
      Windows NT/2000/XP Pro:  c:\winnt\system32\drivers\etc\hosts
      Windows XP Home: c:\windows\system32\drivers\etc\hosts
      Windows Vista/7/8: c:\windows\system32\drivers\etc\hosts

      You may need administrator access for Windows NT/2000/XP/Vista/7/8, you can gain this by logging in as an Administrator or by right clicking on Notepad in the start menu and then clicking on Run As Administrator. Then open the file listed above.

      NOTE: Hosts is the name of the hosts file and not another directory name. It does not have an file extension (extensions are the .exe, .txt, .doc, etc. endings to filenames) and so appears to be another directory in the example above.

      This file should be edited with a text editor, such as Notepad, and not a word processor, such as Microsoft Word.

    • Add this line to the Hosts file at the bottom where 0.0.0.0 is the IP address and your-domain-name.com is the domain name.
      0.0.0.0     your-domain-name.com

 

  • Save your changes.
  • Once you are done with this entry you can delete the line from your Hosts file and save it.

    NOTE: Windows users should verify that they are showing extensions for all file types. This will help verify that the Hosts file is named correctly. To reset Windows to show all file extensions, double click on My Computer. Go to View Menu (Win95/98/ME) or Tools Menu (Win2000/XP), and select Folder Options. Click the View tab. In the Files and Folders section, DESELECT (uncheck) the item named "Hide file extensions for known file types". Click Apply, and then click OK.



https://support.aiso.net/index.php?/Knowledgebase/Article/View/240/2/how-do-i-add-my-domain-name-to-my-computers-host-file

'Programming > C,CPP,CS' 카테고리의 다른 글

[CPP] Windows Service 간단하게 만들기  (0) 2017.10.17
WaitForMultipleObjects  (0) 2017.04.19
[VS2013] 힙이 손상되었습니다.  (0) 2017.04.05
Visual Studio 2013 갑자기 느려질때  (0) 2017.04.04
AES Block cipher modes  (0) 2017.03.29

[VS2013] 힙이 손상되었습니다.

Programming/C,CPP,CS 2017. 4. 5. 14:30 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

[VS2013] 힙이 손상되었습니다.



프로그램이 사용하던 메모리를 해제한 후에 다음과 같이 에러가 발생하는 경우



처음에 메모리 할당시 적절한 크기를 할당하지 못하여 발생하는 경우가 있다.




최고 malloc 시 제대로 크기 계산을 못하여 



해당 메모리를 해제 할때 다음과 같은 에러가 발생 함.