<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>c# - HaiNH</title>
	<atom:link href="https://hainh.dev/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>https://hainh.dev</link>
	<description></description>
	<lastBuildDate>Thu, 16 Oct 2025 17:24:25 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://hainh.dev/wp-content/uploads/2025/10/cropped-logomyblog-32x32.png</url>
	<title>c# - HaiNH</title>
	<link>https://hainh.dev</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">249252746</site>	<item>
		<title>DatagridView bị tình trạng giật lag nhấp nháy khi cuộn dòng trong winform</title>
		<link>https://hainh.dev/datagridview-bi-tinh-trang-giat-lag-nhap-nhay-khi-cuon-dong-trong-winform/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=datagridview-bi-tinh-trang-giat-lag-nhap-nhay-khi-cuon-dong-trong-winform</link>
					<comments>https://hainh.dev/datagridview-bi-tinh-trang-giat-lag-nhap-nhay-khi-cuon-dong-trong-winform/#respond</comments>
		
		<dc:creator><![CDATA[NGUYỄN HOÀNG HẢI]]></dc:creator>
		<pubDate>Thu, 27 Oct 2022 06:01:41 +0000</pubDate>
				<category><![CDATA[Lập trình ứng dụng]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[lập trình ứng dụng]]></category>
		<category><![CDATA[Winform]]></category>
		<guid isPermaLink="false">https://hainh2k3.com/?p=4194</guid>

					<description><![CDATA[<p>Nếu các bạn sử dụng DataGridView mà khi cuộn các dòng dữ liệu gặp tình trạng giật lag, nhấp nháy (flickering) thì hãy sử dụng giải pháp set DoubleBuffered = True, gần như tất cả control đều có thuộc tính này nhưng DataGridView thì lại bị ẩn đi. Chúng ta chỉ cẩn sử dụng đoạn...</p>
<p>The post <a href="https://hainh.dev/datagridview-bi-tinh-trang-giat-lag-nhap-nhay-khi-cuon-dong-trong-winform/">DatagridView bị tình trạng giật lag nhấp nháy khi cuộn dòng trong winform</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Nếu các bạn sử dụng DataGridView mà khi cuộn các dòng dữ liệu gặp tình trạng giật lag, nhấp nháy (flickering) thì hãy sử dụng giải pháp  set DoubleBuffered = True, gần như tất cả control đều có thuộc tính này nhưng DataGridView thì lại bị ẩn đi. Chúng ta chỉ cẩn sử dụng đoạn code dưới đây để bật thuộc tính này cho các control cần thiết.</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-disabled cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(1 * 0.6 * .875rem);--cbp-line-highlight-color:rgba(0, 0, 0, 0.2);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>public static void SetDoubleBuffered(Control control)
{
  // set instance non-public property with name "DoubleBuffered" to true
  typeof(Control).InvokeMember("DoubleBuffered",
      BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
      null, control, new object[] { true });
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">static</span><span style="color: #000000"> </span><span style="color: #0000FF">void</span><span style="color: #000000"> </span><span style="color: #795E26">SetDoubleBuffered</span><span style="color: #000000">(</span><span style="color: #267F99">Control</span><span style="color: #000000"> </span><span style="color: #001080">control</span><span style="color: #000000">)</span></span>
<span class="line"><span style="color: #000000">{</span></span>
<span class="line"><span style="color: #008000">  // set instance non-public property with name &quot;DoubleBuffered&quot; to true</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #0000FF">typeof</span><span style="color: #000000">(</span><span style="color: #267F99">Control</span><span style="color: #000000">).</span><span style="color: #795E26">InvokeMember</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;DoubleBuffered&quot;</span><span style="color: #000000">,</span></span>
<span class="line"><span style="color: #000000">      </span><span style="color: #001080">BindingFlags</span><span style="color: #000000">.</span><span style="color: #001080">SetProperty</span><span style="color: #000000"> | </span><span style="color: #001080">BindingFlags</span><span style="color: #000000">.</span><span style="color: #001080">Instance</span><span style="color: #000000"> | </span><span style="color: #001080">BindingFlags</span><span style="color: #000000">.</span><span style="color: #001080">NonPublic</span><span style="color: #000000">,</span></span>
<span class="line"><span style="color: #000000">      </span><span style="color: #0000FF">null</span><span style="color: #000000">, </span><span style="color: #001080">control</span><span style="color: #000000">, </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #0000FF">object</span><span style="color: #000000">[] { </span><span style="color: #0000FF">true</span><span style="color: #000000"> });</span></span>
<span class="line"><span style="color: #000000">}</span></span></code></pre></div>



<p>Khi sử dụng chỉ cần gọi vd: gdv.SetDoubleBuffered() ở form_load chẳng hạn, vd kết quả sẽ như dưới đây</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="537" height="301" data-attachment-id="4195" data-permalink="https://hainh.dev/datagridview-bi-tinh-trang-giat-lag-nhap-nhay-khi-cuon-dong-trong-winform/setdoublebuffered-true/" data-orig-file="https://hainh.dev/wp-content/uploads/2022/10/SetDoubleBuffered-true-1.gif" data-orig-size="537,301" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="SetDoubleBuffered-true" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2022/10/SetDoubleBuffered-true-1-300x168.gif" data-large-file="https://hainh.dev/wp-content/uploads/2022/10/SetDoubleBuffered-true-1.gif" src="https://hainh.dev/wp-content/uploads/2022/10/SetDoubleBuffered-true-1.gif" alt="" class="wp-image-4195"/></figure><p>The post <a href="https://hainh.dev/datagridview-bi-tinh-trang-giat-lag-nhap-nhay-khi-cuon-dong-trong-winform/">DatagridView bị tình trạng giật lag nhấp nháy khi cuộn dòng trong winform</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://hainh.dev/datagridview-bi-tinh-trang-giat-lag-nhap-nhay-khi-cuon-dong-trong-winform/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4194</post-id>	</item>
		<item>
		<title>Phát hiện và đọc số container bằng camera</title>
		<link>https://hainh.dev/phat-hien-va-doc-so-container-bang-camera/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=phat-hien-va-doc-so-container-bang-camera</link>
					<comments>https://hainh.dev/phat-hien-va-doc-so-container-bang-camera/#comments</comments>
		
		<dc:creator><![CDATA[NGUYỄN HOÀNG HẢI]]></dc:creator>
		<pubDate>Fri, 01 Jan 2021 04:33:00 +0000</pubDate>
				<category><![CDATA[Dự án]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[computer vision]]></category>
		<category><![CDATA[container]]></category>
		<category><![CDATA[dự án]]></category>
		<category><![CDATA[logistics]]></category>
		<category><![CDATA[yolo]]></category>
		<guid isPermaLink="false">https://hainh2k3.com/?p=4080</guid>

					<description><![CDATA[<p>Ứng dụng hệ thống trong việc kiểm soát, ghi chép hành trình vỏ container ra vào kho bãi &#8230; Hệ thống đang được thử nghiệm có độ chính xác 87% nếu để camera tự do, phát hiện thời gian thực và hơn 98% nếu góc ảnh camera được cố định. Một số kết quả khi...</p>
<p>The post <a href="https://hainh.dev/phat-hien-va-doc-so-container-bang-camera/">Phát hiện và đọc số container bằng camera</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Ứng dụng hệ thống trong việc kiểm soát, ghi chép hành trình vỏ container ra vào kho bãi &#8230;</p>



<p>Hệ thống đang được thử nghiệm có độ chính xác 87% nếu để camera tự do, phát hiện thời gian thực và hơn 98% nếu góc ảnh camera được cố định. </p>



<figure class="wp-block-image size-full"><img decoding="async" width="1922" height="1041" data-attachment-id="4081" data-permalink="https://hainh.dev/phat-hien-va-doc-so-container-bang-camera/data-train/" data-orig-file="https://hainh.dev/wp-content/uploads/2022/10/data-train-1.jpg" data-orig-size="1922,1041" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="data-train" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2022/10/data-train-1-300x162.jpg" data-large-file="https://hainh.dev/wp-content/uploads/2022/10/data-train-1-1024x555.jpg" src="https://hainh.dev/wp-content/uploads/2022/10/data-train-1.jpg" alt="" class="wp-image-4081" srcset="https://hainh.dev/wp-content/uploads/2022/10/data-train-1.jpg 1922w, https://hainh.dev/wp-content/uploads/2022/10/data-train-1-300x162.jpg 300w, https://hainh.dev/wp-content/uploads/2022/10/data-train-1-1024x555.jpg 1024w, https://hainh.dev/wp-content/uploads/2022/10/data-train-1-768x416.jpg 768w, https://hainh.dev/wp-content/uploads/2022/10/data-train-1-1536x832.jpg 1536w" sizes="(max-width: 1922px) 100vw, 1922px" /><figcaption>Data ảnh dùng để huấn luyện, gắn nhãn</figcaption></figure>



<p>Một số kết quả khi thử nghiệm hệ thống</p>



<figure class="wp-block-image size-full"><img decoding="async" width="642" height="512" data-attachment-id="4082" data-permalink="https://hainh.dev/phat-hien-va-doc-so-container-bang-camera/z3049903489648_d6958f0e3aaa905c4a8c851f6be6b595/" data-orig-file="https://hainh.dev/wp-content/uploads/2022/10/z3049903489648_d6958f0e3aaa905c4a8c851f6be6b595-1.jpg" data-orig-size="642,512" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="z3049903489648_d6958f0e3aaa905c4a8c851f6be6b595" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2022/10/z3049903489648_d6958f0e3aaa905c4a8c851f6be6b595-1-300x239.jpg" data-large-file="https://hainh.dev/wp-content/uploads/2022/10/z3049903489648_d6958f0e3aaa905c4a8c851f6be6b595-1.jpg" src="https://hainh.dev/wp-content/uploads/2022/10/z3049903489648_d6958f0e3aaa905c4a8c851f6be6b595-1.jpg" alt="" class="wp-image-4082" srcset="https://hainh.dev/wp-content/uploads/2022/10/z3049903489648_d6958f0e3aaa905c4a8c851f6be6b595-1.jpg 642w, https://hainh.dev/wp-content/uploads/2022/10/z3049903489648_d6958f0e3aaa905c4a8c851f6be6b595-1-300x239.jpg 300w" sizes="(max-width: 642px) 100vw, 642px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="599" height="800" data-attachment-id="4083" data-permalink="https://hainh.dev/phat-hien-va-doc-so-container-bang-camera/z3372972792370_cc9e135d49a7ab3cd342b61ba357ebc1/" data-orig-file="https://hainh.dev/wp-content/uploads/2022/10/z3372972792370_cc9e135d49a7ab3cd342b61ba357ebc1-1.jpg" data-orig-size="599,800" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="z3372972792370_cc9e135d49a7ab3cd342b61ba357ebc1" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2022/10/z3372972792370_cc9e135d49a7ab3cd342b61ba357ebc1-1-225x300.jpg" data-large-file="https://hainh.dev/wp-content/uploads/2022/10/z3372972792370_cc9e135d49a7ab3cd342b61ba357ebc1-1.jpg" src="https://hainh.dev/wp-content/uploads/2022/10/z3372972792370_cc9e135d49a7ab3cd342b61ba357ebc1-1.jpg" alt="" class="wp-image-4083" srcset="https://hainh.dev/wp-content/uploads/2022/10/z3372972792370_cc9e135d49a7ab3cd342b61ba357ebc1-1.jpg 599w, https://hainh.dev/wp-content/uploads/2022/10/z3372972792370_cc9e135d49a7ab3cd342b61ba357ebc1-1-225x300.jpg 225w" sizes="(max-width: 599px) 100vw, 599px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="820" height="439" data-attachment-id="4084" data-permalink="https://hainh.dev/phat-hien-va-doc-so-container-bang-camera/z3050125720823_30a4b4f141aa236650e013cd0777539d/" data-orig-file="https://hainh.dev/wp-content/uploads/2022/10/z3050125720823_30a4b4f141aa236650e013cd0777539d-1.jpg" data-orig-size="820,439" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="z3050125720823_30a4b4f141aa236650e013cd0777539d" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2022/10/z3050125720823_30a4b4f141aa236650e013cd0777539d-1-300x161.jpg" data-large-file="https://hainh.dev/wp-content/uploads/2022/10/z3050125720823_30a4b4f141aa236650e013cd0777539d-1.jpg" src="https://hainh.dev/wp-content/uploads/2022/10/z3050125720823_30a4b4f141aa236650e013cd0777539d-1.jpg" alt="" class="wp-image-4084" srcset="https://hainh.dev/wp-content/uploads/2022/10/z3050125720823_30a4b4f141aa236650e013cd0777539d-1.jpg 820w, https://hainh.dev/wp-content/uploads/2022/10/z3050125720823_30a4b4f141aa236650e013cd0777539d-1-300x161.jpg 300w, https://hainh.dev/wp-content/uploads/2022/10/z3050125720823_30a4b4f141aa236650e013cd0777539d-1-768x411.jpg 768w" sizes="(max-width: 820px) 100vw, 820px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1557" height="1093" data-attachment-id="4085" data-permalink="https://hainh.dev/phat-hien-va-doc-so-container-bang-camera/z3050105294787_43710edfc7e7009947e8f87fcebf0eed/" data-orig-file="https://hainh.dev/wp-content/uploads/2022/10/z3050105294787_43710edfc7e7009947e8f87fcebf0eed-1.jpg" data-orig-size="1557,1093" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="z3050105294787_43710edfc7e7009947e8f87fcebf0eed" data-image-description="" data-image-caption="" data-medium-file="https://hainh.dev/wp-content/uploads/2022/10/z3050105294787_43710edfc7e7009947e8f87fcebf0eed-1-300x211.jpg" data-large-file="https://hainh.dev/wp-content/uploads/2022/10/z3050105294787_43710edfc7e7009947e8f87fcebf0eed-1-1024x719.jpg" src="https://hainh.dev/wp-content/uploads/2022/10/z3050105294787_43710edfc7e7009947e8f87fcebf0eed-1.jpg" alt="" class="wp-image-4085" srcset="https://hainh.dev/wp-content/uploads/2022/10/z3050105294787_43710edfc7e7009947e8f87fcebf0eed-1.jpg 1557w, https://hainh.dev/wp-content/uploads/2022/10/z3050105294787_43710edfc7e7009947e8f87fcebf0eed-1-300x211.jpg 300w, https://hainh.dev/wp-content/uploads/2022/10/z3050105294787_43710edfc7e7009947e8f87fcebf0eed-1-1024x719.jpg 1024w, https://hainh.dev/wp-content/uploads/2022/10/z3050105294787_43710edfc7e7009947e8f87fcebf0eed-1-768x539.jpg 768w, https://hainh.dev/wp-content/uploads/2022/10/z3050105294787_43710edfc7e7009947e8f87fcebf0eed-1-1536x1078.jpg 1536w" sizes="(max-width: 1557px) 100vw, 1557px" /></figure>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe class="youtube-player" width="751" height="423" src="https://www.youtube.com/embed/BpehyU2ZfYc?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=en-US&#038;autohide=2&#038;start=2&#038;wmode=transparent" allowfullscreen="true" style="border:0;" sandbox="allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox"></iframe>
</div></figure><p>The post <a href="https://hainh.dev/phat-hien-va-doc-so-container-bang-camera/">Phát hiện và đọc số container bằng camera</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://hainh.dev/phat-hien-va-doc-so-container-bang-camera/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4080</post-id>	</item>
		<item>
		<title>C# lấy địa chỉ IP internet của máy tính</title>
		<link>https://hainh.dev/c-lay-dia-chi-ip-internet-cua-may-tinh/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=c-lay-dia-chi-ip-internet-cua-may-tinh</link>
					<comments>https://hainh.dev/c-lay-dia-chi-ip-internet-cua-may-tinh/#respond</comments>
		
		<dc:creator><![CDATA[NGUYỄN HOÀNG HẢI]]></dc:creator>
		<pubDate>Thu, 28 Feb 2019 02:52:15 +0000</pubDate>
				<category><![CDATA[Lập trình ứng dụng]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[lập trình ứng dụng]]></category>
		<guid isPermaLink="false">https://hainh2k3.com/?p=2523</guid>

					<description><![CDATA[<p>Lấy kết quả trả về khi chạy Command Prompt: Lấy địa chỉ IP thông qua cách sử dụng CMD:Chú ý: using System.Text.RegularExpressions; Một cách khác lấy địa chỉ IP thông qua trang http://ipinfo.io/ip</p>
<p>The post <a href="https://hainh.dev/c-lay-dia-chi-ip-internet-cua-may-tinh/">C# lấy địa chỉ IP internet của máy tính</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Lấy kết quả trả về khi chạy Command Prompt:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-disabled cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>public static string RunCMD(string cmd)
{
  Process cmdProcess;
  cmdProcess = new Process();
  cmdProcess.StartInfo.FileName = "cmd.exe";
  cmdProcess.StartInfo.Arguments = "/c " + cmd;
  cmdProcess.StartInfo.RedirectStandardOutput = true;
  cmdProcess.StartInfo.UseShellExecute = false;
  cmdProcess.StartInfo.CreateNoWindow = true;
  cmdProcess.Start();
  string output = cmdProcess.StandardOutput.ReadToEnd();
  cmdProcess.WaitForExit();
  if (String.IsNullOrEmpty(output))
    return "";
  return output;
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">static</span><span style="color: #000000"> </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #795E26">RunCMD</span><span style="color: #000000">(</span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">cmd</span><span style="color: #000000">)</span></span>
<span class="line"><span style="color: #000000">{</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #267F99">Process</span><span style="color: #000000"> </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000"> = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #267F99">Process</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #001080">StartInfo</span><span style="color: #000000">.</span><span style="color: #001080">FileName</span><span style="color: #000000"> = </span><span style="color: #A31515">&quot;cmd.exe&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #001080">StartInfo</span><span style="color: #000000">.</span><span style="color: #001080">Arguments</span><span style="color: #000000"> = </span><span style="color: #A31515">&quot;/c &quot;</span><span style="color: #000000"> + </span><span style="color: #001080">cmd</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #001080">StartInfo</span><span style="color: #000000">.</span><span style="color: #001080">RedirectStandardOutput</span><span style="color: #000000"> = </span><span style="color: #0000FF">true</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #001080">StartInfo</span><span style="color: #000000">.</span><span style="color: #001080">UseShellExecute</span><span style="color: #000000"> = </span><span style="color: #0000FF">false</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #001080">StartInfo</span><span style="color: #000000">.</span><span style="color: #001080">CreateNoWindow</span><span style="color: #000000"> = </span><span style="color: #0000FF">true</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #795E26">Start</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">output</span><span style="color: #000000"> = </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #001080">StandardOutput</span><span style="color: #000000">.</span><span style="color: #795E26">ReadToEnd</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #001080">cmdProcess</span><span style="color: #000000">.</span><span style="color: #795E26">WaitForExit</span><span style="color: #000000">();</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #AF00DB">if</span><span style="color: #000000"> (</span><span style="color: #001080">String</span><span style="color: #000000">.</span><span style="color: #795E26">IsNullOrEmpty</span><span style="color: #000000">(</span><span style="color: #001080">output</span><span style="color: #000000">))</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #A31515">&quot;&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #001080">output</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">}</span></span></code></pre></div>



<p>Lấy địa chỉ IP thông qua cách sử dụng CMD:<br>Chú ý: using System.Text.RegularExpressions;</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-disabled cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>public static string GetIP()
{
  try
  {
    string output = RunCMD("nslookup myip.opendns.com. resolver1.opendns.com");
    var ip = Regex.Matches(output, @"\b(?:(?:25&#91;0-5&#93;|2&#91;0-4&#93;&#91;0-9&#93;|&#91;01&#93;?&#91;0-9&#93;&#91;0-9&#93;?)\.){3}(?:25&#91;0-5&#93;|2&#91;0-4&#93;&#91;0-9&#93;|&#91;01&#93;?&#91;0-9&#93;&#91;0-9&#93;?)\b");
    return ip&#91;1&#93;.Value;
  }
  catch
  {
    return "127.0.0.1";
  }
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">static</span><span style="color: #000000"> </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #795E26">GetIP</span><span style="color: #000000">()</span></span>
<span class="line"><span style="color: #000000">{</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #AF00DB">try</span></span>
<span class="line"><span style="color: #000000">  {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">output</span><span style="color: #000000"> = </span><span style="color: #795E26">RunCMD</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;nslookup myip.opendns.com. resolver1.opendns.com&quot;</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #0000FF">var</span><span style="color: #000000"> </span><span style="color: #001080">ip</span><span style="color: #000000"> = </span><span style="color: #001080">Regex</span><span style="color: #000000">.</span><span style="color: #795E26">Matches</span><span style="color: #000000">(</span><span style="color: #001080">output</span><span style="color: #000000">, </span><span style="color: #A31515">@&quot;\b(?:(?:25&#91;0-5&#93;|2&#91;0-4&#93;&#91;0-9&#93;|&#91;01&#93;?&#91;0-9&#93;&#91;0-9&#93;?)\.){3}(?:25&#91;0-5&#93;|2&#91;0-4&#93;&#91;0-9&#93;|&#91;01&#93;?&#91;0-9&#93;&#91;0-9&#93;?)\b&quot;</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #001080">ip</span><span style="color: #000000">&#91;</span><span style="color: #098658">1</span><span style="color: #000000">&#93;.</span><span style="color: #001080">Value</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  }</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #AF00DB">catch</span></span>
<span class="line"><span style="color: #000000">  {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #A31515">&quot;127.0.0.1&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  }</span></span>
<span class="line"><span style="color: #000000">}</span></span></code></pre></div>



<p>Một cách khác lấy địa chỉ IP thông qua trang http://ipinfo.io/ip</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-disabled cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#000000;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#FFFFFF"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#000000;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>public static string getIpInternet()
{
  try
  {
    using (System.Net.WebClient client = new System.Net.WebClient())
    {
      string ip = client.DownloadString("http://ipinfo.io/ip");
      ip = ip.Replace("\r", "").Replace("\n", "");
      return ip;
    }
  }
  catch
  {
    return "127.0.0.1";
  }
}</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki light-plus" style="background-color: #FFFFFF" tabindex="0"><code><span class="line"><span style="color: #0000FF">public</span><span style="color: #000000"> </span><span style="color: #0000FF">static</span><span style="color: #000000"> </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #795E26">getIpInternet</span><span style="color: #000000">()</span></span>
<span class="line"><span style="color: #000000">{</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #AF00DB">try</span></span>
<span class="line"><span style="color: #000000">  {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #AF00DB">using</span><span style="color: #000000"> (</span><span style="color: #267F99">System</span><span style="color: #000000">.</span><span style="color: #267F99">Net</span><span style="color: #000000">.</span><span style="color: #267F99">WebClient</span><span style="color: #000000"> </span><span style="color: #001080">client</span><span style="color: #000000"> = </span><span style="color: #0000FF">new</span><span style="color: #000000"> </span><span style="color: #267F99">System</span><span style="color: #000000">.</span><span style="color: #267F99">Net</span><span style="color: #000000">.</span><span style="color: #267F99">WebClient</span><span style="color: #000000">())</span></span>
<span class="line"><span style="color: #000000">    {</span></span>
<span class="line"><span style="color: #000000">      </span><span style="color: #0000FF">string</span><span style="color: #000000"> </span><span style="color: #001080">ip</span><span style="color: #000000"> = </span><span style="color: #001080">client</span><span style="color: #000000">.</span><span style="color: #795E26">DownloadString</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;http://ipinfo.io/ip&quot;</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">      </span><span style="color: #001080">ip</span><span style="color: #000000"> = </span><span style="color: #001080">ip</span><span style="color: #000000">.</span><span style="color: #795E26">Replace</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;</span><span style="color: #EE0000">\r</span><span style="color: #A31515">&quot;</span><span style="color: #000000">, </span><span style="color: #A31515">&quot;&quot;</span><span style="color: #000000">).</span><span style="color: #795E26">Replace</span><span style="color: #000000">(</span><span style="color: #A31515">&quot;</span><span style="color: #EE0000">\n</span><span style="color: #A31515">&quot;</span><span style="color: #000000">, </span><span style="color: #A31515">&quot;&quot;</span><span style="color: #000000">);</span></span>
<span class="line"><span style="color: #000000">      </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #001080">ip</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">    }</span></span>
<span class="line"><span style="color: #000000">  }</span></span>
<span class="line"><span style="color: #000000">  </span><span style="color: #AF00DB">catch</span></span>
<span class="line"><span style="color: #000000">  {</span></span>
<span class="line"><span style="color: #000000">    </span><span style="color: #AF00DB">return</span><span style="color: #000000"> </span><span style="color: #A31515">&quot;127.0.0.1&quot;</span><span style="color: #000000">;</span></span>
<span class="line"><span style="color: #000000">  }</span></span>
<span class="line"><span style="color: #000000">}</span></span></code></pre></div>



<p></p><p>The post <a href="https://hainh.dev/c-lay-dia-chi-ip-internet-cua-may-tinh/">C# lấy địa chỉ IP internet của máy tính</a> first appeared on <a href="https://hainh.dev">HaiNH</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://hainh.dev/c-lay-dia-chi-ip-internet-cua-may-tinh/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2523</post-id>	</item>
	</channel>
</rss>
