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");







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

천안 코딩 과외합니다.

정보올림피아드 2017. 8. 8. 13:37 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

지역 : 천안, 아산, 청주

 

 

 

강의 과목 : 프로그래밍, 정보올림피아드, CCNA, CCNP, 코딩, 아두이노, 로봇

 

 

 

경력 : 지도학생) 2013 초등부 정보올림피아드 전국대회 은상 수상

 

         전) 서울 서울특별시립종합직업전문학교 외부강사

 

         전) 청주 그린컴퓨터학원 프로그래밍 강사

 

         전) 천안 그린컴퓨터학원 프로그래밍 강사

 

         전) 아산소재 대학교 시간강사

 

         전) 천안소재 대학교 시간강사

 

 

 

         현) 대학원 박사과정 재학중

 

         현) 기업부설연구소 연구원 근무중

 

 

 

 

과외 개설 조건 : 그룹 4인 이상시 개설 

( 현재 서울 거주중이라 주말 4인 이상 가능 시 강의 개설합니다. )

 

 

과외 장소 : 자택 / 학원 / 스터디룸 / ...... 모두 가능합니다.

 

 

 

 

자세한 문의는

 

 

대기 문의 및 올림피아드 대회 정보에 대한 문의도 주셔도 됩니다.

 

tansanc23@gmail.com 으로 문의해 주세요.

 

 

 

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

지역 : 천안, 아산, 청주


종목 : 프로그래밍, 정보올림피아드, CCNA, CCNP


경력 : 지도학생) 2013 초등부 정보올림피아드 전국대회 은상 수상

         전) 서울 서울특별시립종합직업전문학교 외부강사

         전) 천안 그린컴퓨터학원 프로그래밍 강사

         전) 청주 그린컴퓨터학원 프로그래밍 강사

         전) 아산소재 대학교 시간강사

         전) 천안소재 대학교 시간강사


         현) 대학원 박사과정 재학중

         현) 기업부설연구소 연구원 근무중




자세한 문의는


tansanc23@gmail.com 으로 문의해 주세요.

공일공-구구육이-일사일칠



[Python] List 정렬 프로그램 구현

Programming/Python 2017. 2. 6. 20:30 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

[Python] List 정렬 프로그램 구현





List 에 append 로 integer 값을 하나씩 넣은 후


오름차순 정렬하여 출력하는 프로그램








import sys

numberList =[]


for j in range(10):
    i = int(input("input: "))
    numberList.append(i)
    s1= 0
    print("Ori: {0}".format(numberList))
    while s1 < j:
        if numberList[s1] > numberList[s1+1]:
            numberList[s1] ^= numberList[s1+1]
            numberList[s1+1] ^= numberList[s1]
            numberList[s1] ^= numberList[s1+1]
        s1 = s1 + 1
    while s1 > 0:
        if numberList[s1] < numberList[s1-1]:
            numberList[s1] ^= numberList[s1-1]
            numberList[s1-1] ^= numberList[s1]
            numberList[s1] ^= numberList[s1-1]
        s1 = s1 - 1
    print("Sorted: {0}".format(numberList))

print(numberList)








import sys

numberList =[]
indexList =[]


for j in range(10):
    i = int(input("input: "))
    numberList.append(i)
    indexList.append(0)
    for k in range(len(numberList)-1):
        if i < numberList[k]:
            indexList[k] = indexList[k] + 1
        else:
            indexList[j] = indexList[j] + 1
    print("Ori: {0}".format(numberList))
    print("Sorted: {0}".format(indexList))
    for k1 in range(len(numberList)):
        for k2 in range(len(numberList)):
            if k1 == indexList[k2]:
                sys.stdout.write(str(numberList[k2]))
                sys.stdout.write(" ")
                break
    sys.stdout.write("\n")

print(numberList)






 

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

[Python/OpenCV] Near-Duplicate Image Detection #2  (0) 2020.06.02
[Python/OpenCV] Near-Duplicate Image Detection #1  (0) 2020.06.02
[Python 3.6] * 찍기  (0) 2017.02.02

Java JNetPcap Library Packet Capture

Programming/JNetPcap 2016. 9. 20. 13:46 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Java JNetPcap Library Packet Capture 


pcap File




테스트 환경 : Win7 64bit, Eclipse, Java 1.8



이클립스와


자바는 설치되어있다고 가정합니다.





JNetPcap 라이브러리 다운로드


http://jnetpcap.com/download



저는 x84_64



압축을 풀면





jnetpcap.jar, jnetpcap.dll



두 개의 파일이 보입니다.



1. jnetpcap.jar 은 Eclipse 프로젝트에서 참조 할 수 있도록






Package Explorer > Properties > Java Build Path > Libraries > Add JARs 나 Add External JARs 로 추가하여 줍니다.



다운받은 경로보다는


해당 프로젝트 Eclipse Workspace 내에 두는것을 추천합니다.




한글 경로 때문에 안되는 경우도 있습니다,



2. jnetpcap.dll





C:\Windows\System32 경로에 jnetpcap.dll 파일을 복사하여 줍니다.









이제 설정은 끝났습니다.




테스트 코드는 다음과 같습니다.










import java.io.File;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;

import org.jnetpcap.ByteBufferHandler;
import org.jnetpcap.Pcap;
import org.jnetpcap.PcapDumper;
import org.jnetpcap.PcapHeader;
import org.jnetpcap.PcapIf;

public class Test1 {
	public static void main(String[] args) {
		// pcap.loop(x, dumpHandler, dumper); x 개 패킷을
		// String ofile = "tmp-capture-file.cap"; tmp-capture-file.cap 파일로 저장


		List alldevs = new ArrayList(); // Will be filled with
														// NICs
		StringBuilder errbuf = new StringBuilder(); // For any error msgs

		/***************************************************************************
		 * First get a list of devices on this system
		 **************************************************************************/
		int r = Pcap.findAllDevs(alldevs, errbuf);
		if (r == Pcap.NOT_OK || alldevs.isEmpty()) {
			System.err.printf("Can't read list of devices, error is %s\n", errbuf.toString());
			return;
		}
		PcapIf device = alldevs.get(0); // We know we have atleast 1 device

		/***************************************************************************
		 * Second we open up the selected device
		 **************************************************************************/
		int snaplen = 64 * 1024; // Capture all packets, no trucation
		int flags = Pcap.MODE_PROMISCUOUS; // capture all packets
		int timeout = 10 * 1000; // 10 seconds in millis
		Pcap pcap = Pcap.openLive(device.getName(), snaplen, flags, timeout, errbuf);
		if (pcap == null) {
			System.err.printf("Error while opening device for capture: %s\n", errbuf.toString());
			return;
		}

		/***************************************************************************
		 * Third we create a PcapDumper and associate it with the pcap capture
		 ***************************************************************************/
		String ofile = "tmp-capture-file.cap";
		PcapDumper dumper = pcap.dumpOpen(ofile); // output file

		/***************************************************************************
		 * Fouth we create a packet handler which receives packets and tells the
		 * dumper to write those packets to its output file
		 **************************************************************************/
		ByteBufferHandler dumpHandler = new ByteBufferHandler() {

			public void nextPacket(PcapHeader arg0, ByteBuffer arg1, PcapDumper arg2) {
				// TODO Auto-generated method stub
				dumper.dump(arg0, arg1);
			}
		};

		/***************************************************************************
		 * Fifth we enter the loop and tell it to capture 10 packets. We pass in
		 * the dumper created in step 3
		 **************************************************************************/
		pcap.loop(10, dumpHandler, dumper);

		File file = new File(ofile);
		System.out.printf("%s file has %d bytes in it!\n", ofile, file.length());

		/***************************************************************************
		 * Last thing to do is close the dumper and pcap handles
		 **************************************************************************/
		dumper.close(); // Won't be able to delete without explicit close
		pcap.close();

		if (file.exists()) {
			// file.delete(); // Cleanup
		}	
	}
}


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

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

텍스트 읽어주는 프로그램, 사이트


텍스트로 작성된 것을 읽어주는 프로그램과 사이트 입니다.



프로그램 테스트용으로 음성파일이 필요한데


마땅한 음성파일을 찾지 못해서



신문 기사 긁어 넣고 쓰고 있네요 ㅋ



JetSpech.zip





설치 하지 않아도 되고요 이런식으로 텍스트만 붙여 넣고


스타트 버튼(▷)만 눌러주면 소리가 나옵니다.




혹은 웹 브라우저에서 소리가 발생하는 것이 필요하다면


http://www.oddcast.com


에서 음성을 읽어 줍니다.






Free Dia Diagram Editor

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

Free Dia Diagram Editor


http://dia-installer.de/



Screenshot

Dia
More screenshots.

Requirements

The current Dia release has been tested successfully on Windows 8.1, 8, 7, Windows Vista and Windows XP, Linux and Mac OS X.

The download page provides download packages for Mac OS X and Linux as well as information about Dia on older Windows versions.

Troubleshooting

If you encounter any problems with dia, please read through the FAQ first.

You should also check the bug reports.

License

Dia is free software available under the terms of the GNU GNU General Public License, the GPLv2.




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

Log Librarys  (0) 2016.06.27
ATL,CPP,C# dll 배포  (0) 2016.05.27
Windows 버전별 기본 포함 .NET Framework  (0) 2016.04.14
c# dll ClassLibrary 에서 MessageBox.Show(text,title);  (0) 2016.04.06
.Net FrameWork 버전 확인 방법  (0) 2016.04.05
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

지역 : 서울 성동구 인근


종목 : 프로그래밍, 정보올림피아드, CCNA, CCNP


경력 : 지도학생) 2013 초등부 정보올림피아드 전국대회 은상 수상

        지도학생) 정보올림피아드 본선 진출 다수


         전) 서울 서울특별시립종합직업전문학교 외부강사

         전) 천안 그린컴퓨터학원 프로그래밍 강사

         전) 한국기술교육대학교 대학원 컴퓨터공학부 박사과정 수료

         전) 청주 그린컴퓨터학원 프로그래밍 강사

         전) 아산소재 대학교 시간강사

         전) 천안소재 대학교 시간강사



         현) 한국기술교육대학교 평생능력개발 이러닝 운영강사

         현) IT기업 연구소 재직중




자세한 문의는


tansanc23@gmail.com 으로 문의해 주세요.

공일공-구구육이-일사일칠


Java 채팅 소스 예제 #1

Programming/JAVA,JSP 2016. 2. 4. 14:28 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;

import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class Client {
	public static void main(String[] args) {
		JTextField textField;
		JTextArea textArea;
		PrintWriter out;
		try {
			Socket s = new Socket("118.46.60.67", 5555);
			out = new PrintWriter(s.getOutputStream(), true);
			JFrame f = new JFrame("채팅");
			f.setSize(600, 400);
			f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
			textArea = new JTextArea();
			textField = new JTextField(10);
			textField.addActionListener(
					new ActionListener() {
						public void actionPerformed(ActionEvent e) {
						out.println(textField.getText());
						}
					}
			);
			f.add(textField, BorderLayout.SOUTH);
			f.add(textArea, BorderLayout.CENTER);
			f.setVisible(true);
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}

'Programming > JAVA,JSP' 카테고리의 다른 글

ImageFrameTest  (0) 2016.02.05
Java 채팅 프로그램  (0) 2016.02.04
Java CardLayout Test  (0) 2016.01.26
정올 알고리즘 2247 도서관 문제  (0) 2015.11.26
Java Server/Client Code  (2) 2015.11.12