<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-23341943</id><updated>2011-04-21T12:08:09.823-07:00</updated><title type='text'>Win32 Coding</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>17</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-23341943.post-114948623614019475</id><published>2006-06-04T22:40:00.000-07:00</published><updated>2006-06-04T22:43:56.150-07:00</updated><title type='text'>GUI alternatives to Win32</title><content type='html'>If you're looking for alternatives to Win32 for writing GUI applications, but still want to deal with windows at a low level, GTK is a pretty good choice. I've been using it to write simple GUI applications in C targeted at the Linux platform. GTK applications can also be run on Windows using the GTK+ Runtime Environment for Windows available at http://gimp-win.sourceforge.net/stable.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114948623614019475?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114948623614019475/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114948623614019475' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114948623614019475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114948623614019475'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/06/gui-alternatives-to-win32.html' title='GUI alternatives to Win32'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114663313113236391</id><published>2006-05-02T22:04:00.000-07:00</published><updated>2006-05-02T22:12:11.143-07:00</updated><title type='text'>Microsoft: You're a member - I don't want to deal with you</title><content type='html'>I tried to use a member function as a ThreadProc method in the CreateThread call, but it didn't work. The following are all of my attempts at doing it...&lt;br /&gt;&lt;br /&gt;- "&amp;listeners::tossToServer" and "&amp;(listeners::tossToServer)" result in:&lt;br /&gt;error C2664: 'CreateThread': cannot convert parameter 3 frpm 'DWORD (__stdcall listeners::*)(LPVOID)' to 'LPTHREAD_START_ROUTINE'.&lt;br /&gt;I tried casting it to 'LPTHREAD_START_ROUTINE', but that would work either.&lt;br /&gt;&lt;br /&gt;- "tossToServer" results in:&lt;br /&gt;error C3867: 'listeners::tossToServer': function call missing argument list; use '&amp;listeners::tossToServer' to create a pointer to member&lt;br /&gt;&lt;br /&gt;- "&amp;tossToServer" results in:&lt;br /&gt;error C2276: '&amp;'; illegal operation on bound member function expression&lt;br /&gt;&lt;br /&gt;In all of the above, my statements were a little like so:&lt;br /&gt;DWORD dwThreadId;&lt;br /&gt;HANDLE hThread = CreateThread (NULL, 0, Thread_proc_here, Ptr_to_param, 0, &amp;dwThreadId);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;After all that testing and turning, I decided to search the WWW, or more specifically, Google. An article from Microsoft turned up on why we can't use member functions in Win32 API calls. It's available at http://support.microsoft.com/kb/q102352/ but I have an extract of the part you need to read right here:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--- BEGIN QUOTE ---&lt;br /&gt;&lt;br /&gt;The problem is that the function expects a C-style callback, not a pointer to a member function. A major difference is that member functions are called with a hidden argument called the "this" pointer. In addition, the format of the pointer isn't simply the address of the first machine instruction, as a C pointer is. This is particularly true for virtual functions.&lt;br /&gt;&lt;br /&gt;If you want to use a member function as a callback, you can use a static member function. Static member functions do not receive the "this" pointer and their addresses correspond to an instruction to execute.&lt;br /&gt;&lt;br /&gt;Static member functions can only access static data, and therefore to access nonstatic class members, the function needs an object or a pointer to an object. One solution is to pass in the "this" pointer as an argument to the member function.&lt;br /&gt;&lt;br /&gt;--- END QUOTE ---&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114663313113236391?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114663313113236391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114663313113236391' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114663313113236391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114663313113236391'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/05/microsoft-youre-member-i-dont-want-to.html' title='Microsoft: You&apos;re a member - I don&apos;t want to deal with you'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114622307087729865</id><published>2006-04-28T04:16:00.000-07:00</published><updated>2006-04-28T04:17:50.893-07:00</updated><title type='text'>No more Win32 for a while</title><content type='html'>I won't be coding any Win32 for a while as my computer just ended it's life and I'm not too keen on rejuvenating it 'cos the repairs cost a lot - I can get a new desktop for the price of repairing my notebook PC.&lt;br /&gt;&lt;br /&gt;Anyway, hope you have a good time coding with the Win32 API.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114622307087729865?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114622307087729865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114622307087729865' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114622307087729865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114622307087729865'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/04/no-more-win32-for-while.html' title='No more Win32 for a while'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114594059638225136</id><published>2006-04-24T21:46:00.000-07:00</published><updated>2006-04-24T21:49:56.383-07:00</updated><title type='text'>It's been a while</title><content type='html'>I haven't posted since my blog was blocked after it was detected as spam. It was whitelisted after about 2 days, but then there were server problems and so I stepped away from blogging and from Win32 programming.&lt;br /&gt;&lt;br /&gt;Now, I'm back and am hoping to get into Win32 for User Interfaces, Sockets, and Thread to develop a tiny chat application. I have a chat server/client that runs on Linux; this will be a complete re-write targeted at Windows (Win32 platform).&lt;br /&gt;&lt;br /&gt;The first speed-bump I came across was using the 'how' constant for shutdown - the Linux equivalent wasn't supported and SD_BOTH worked only with Winsock2.h. It took me a while to figure out that I have to include Winsock2.h before Windows.h because Windows.h automatically includes Winsock.h.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114594059638225136?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114594059638225136/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114594059638225136' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114594059638225136'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114594059638225136'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/04/its-been-while.html' title='It&apos;s been a while'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114594007778149082</id><published>2006-04-24T21:37:00.000-07:00</published><updated>2006-04-24T21:41:17.796-07:00</updated><title type='text'>Socket Programming in Win32</title><content type='html'>//Socket programming in Win32&lt;br /&gt;//Author: Nitin Reddy Katkam&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//---- chatty_ui.h ----&lt;br /&gt;&lt;br /&gt;#ifndef _CHATTY_UI__H&lt;br /&gt;&lt;br /&gt; #define _CHATTY_UI__H&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; #undef UNICODE&lt;br /&gt; #undef _UNICODE&lt;br /&gt; #define _WINSOCKAPI_   /* Prevent inclusion of winsock.h in windows.h */&lt;br /&gt;&lt;br /&gt; #include &lt;windows.h&gt;&lt;br /&gt; #include &lt;stdio.h&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);&lt;br /&gt; void ExitWithError(char *ac_operation);&lt;br /&gt; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);&lt;br /&gt;&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//---- chatty_sock.h ----&lt;br /&gt;&lt;br /&gt;#ifndef _CHATTY_SOCK__H&lt;br /&gt;&lt;br /&gt; #define _CHATTY_SOCK__H&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; #undef UNICODE&lt;br /&gt; #undef _UNICODE&lt;br /&gt;&lt;br /&gt; #include &lt;string.h&gt;&lt;br /&gt; #include &lt;winsock2.h&gt;&lt;br /&gt;&lt;br /&gt; int initChattySock (char *ac_ipaddr);&lt;br /&gt; void listenChatty ();&lt;br /&gt; void ShutEar();&lt;br /&gt; DWORD WINAPI ServerThreadProc( LPVOID lpParam );&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//---- chatty_ui.cpp ----&lt;br /&gt;&lt;br /&gt;#include "chatty_ui.h"&lt;br /&gt;#include "chatty_sock.h"&lt;br /&gt;&lt;br /&gt;HWND hwnd_edit_ip;&lt;br /&gt;HWND hwnd_button_connect;&lt;br /&gt;HINSTANCE hInstance_g;&lt;br /&gt;&lt;br /&gt;char c_currStatus=0;&lt;br /&gt;&lt;br /&gt;LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {&lt;br /&gt; switch (msg) {&lt;br /&gt;  case WM_COMMAND:&lt;br /&gt;   switch (wParam) {&lt;br /&gt;    case 2: //connect button&lt;br /&gt;     //MessageBox(NULL, "button pressed", "info", MB_OK);&lt;br /&gt;&lt;br /&gt;     c_currStatus=!c_currStatus;&lt;br /&gt;     if (c_currStatus) {&lt;br /&gt;      char buf[256];&lt;br /&gt;      GetWindowText(hwnd_edit_ip, buf, 256);&lt;br /&gt;      initChattySock(buf);&lt;br /&gt;      listenChatty();&lt;br /&gt;&lt;br /&gt;      SetWindowText(hwnd_button_connect, "Disconnect");&lt;br /&gt;     } else {&lt;br /&gt;      ShutEar();&lt;br /&gt;&lt;br /&gt;      SetWindowText(hwnd_button_connect, "Connect");&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     break;&lt;br /&gt;   }&lt;br /&gt;   break;&lt;br /&gt;  case WM_CLOSE:&lt;br /&gt;   DestroyWindow(hwnd);&lt;br /&gt;   break;&lt;br /&gt;  case WM_DESTROY:&lt;br /&gt;   PostQuitMessage(0);&lt;br /&gt;   exit(0);&lt;br /&gt;   break;&lt;br /&gt;  case WM_CREATE:&lt;br /&gt;   hwnd_edit_ip = CreateWindowEx(0, "edit", "0.0.0.0", WS_CHILD|WS_VISIBLE|WS_BORDER, 70, 45, 140, 25, hwnd, (HMENU) 1, hInstance_g, 0);&lt;br /&gt;   hwnd_button_connect = CreateWindowEx(0, "button", "Connect", WS_CHILD|WS_VISIBLE, 220, 45, 75, 25, hwnd, (HMENU) 2, hInstance_g, 0);&lt;br /&gt;   break;&lt;br /&gt;  default:&lt;br /&gt;   return DefWindowProc(hwnd, msg, wParam, lParam);&lt;br /&gt; }&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;void ExitWithError(char *ac_operation) {&lt;br /&gt; printf("Error in %s\r\n", ac_operation);&lt;br /&gt; getchar();&lt;br /&gt; exit(1);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {&lt;br /&gt; hInstance_g=hInstance;&lt;br /&gt; int callRetVal=0;&lt;br /&gt; &lt;br /&gt; WNDCLASSEX wc;&lt;br /&gt; PWNDCLASSEX p_wc = &amp;wc;&lt;br /&gt; int i_wcSize = sizeof(WNDCLASSEX);&lt;br /&gt; memset(p_wc, 0, i_wcSize);&lt;br /&gt;&lt;br /&gt; wc.cbSize=i_wcSize;&lt;br /&gt; wc.lpszClassName="katkam_chatwin";&lt;br /&gt; wc.lpfnWndProc=WndProc;&lt;br /&gt; wc.hInstance=hInstance;&lt;br /&gt; wc.hbrBackground=(HBRUSH) (COLOR_WINDOW+1);&lt;br /&gt;&lt;br /&gt; callRetVal = RegisterClassEx(p_wc); //if the return value is zero, an error occurred&lt;br /&gt; if (!callRetVal) {&lt;br /&gt;  ExitWithError("Window Registration");&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; HWND hwnd = CreateWindowEx(0, "katkam_chatwin", "K-Chat", WS_OVERLAPPEDWINDOW, 0, 0, 320, 200, NULL, NULL, hInstance, NULL);&lt;br /&gt; ShowWindow(hwnd, nCmdShow);&lt;br /&gt; UpdateWindow(hwnd);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; MSG msg;&lt;br /&gt; MSG *p_msg=&amp;msg;&lt;br /&gt; while (GetMessage(p_msg, hwnd, 0, 0)) {&lt;br /&gt;  TranslateMessage(p_msg);&lt;br /&gt;  DispatchMessage(p_msg);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; return (int) msg.wParam;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//---- chatty_sock.cpp ----&lt;br /&gt;&lt;br /&gt;#include "chatty_ui.h"&lt;br /&gt;#include "chatty_sock.h"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SOCKET sock1;&lt;br /&gt;SOCKET sock2;&lt;br /&gt;&lt;br /&gt;struct sockaddr_in saddr_in;&lt;br /&gt;struct sockaddr *p_saddr =  (struct sockaddr *) &amp;saddr_in;&lt;br /&gt;int sockaddr_len = sizeof(struct sockaddr_in);&lt;br /&gt;struct sockaddr_in saddr_in2;&lt;br /&gt;struct sockaddr *p_saddr2 =  (struct sockaddr *) &amp;saddr_in2;&lt;br /&gt;&lt;br /&gt;HANDLE hThread;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int initChattySock (char *ac_ipaddr) {&lt;br /&gt; WSADATA wsaData;&lt;br /&gt; if (WSAStartup(MAKEWORD(1,1), &amp;wsaData) != 0) {&lt;br /&gt;  ExitWithError("WSAStartup");&lt;br /&gt;  //fprintf(stderr, "WSAStartup failed.\n");&lt;br /&gt;  //getchar();&lt;br /&gt;  //exit(1);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; saddr_in.sin_addr.S_un.S_addr = inet_addr(ac_ipaddr);&lt;br /&gt; saddr_in.sin_family=AF_INET;&lt;br /&gt; saddr_in.sin_port=htons(1210);&lt;br /&gt; memset(saddr_in.sin_zero, 0, 8);&lt;br /&gt;&lt;br /&gt; sock1 = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);&lt;br /&gt; if (sock1 == INVALID_SOCKET) {&lt;br /&gt;  ExitWithError("socket");&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void listenChatty () {&lt;br /&gt; bind(sock1, p_saddr, sockaddr_len);&lt;br /&gt; listen(sock1, 0);&lt;br /&gt; &lt;br /&gt; DWORD dwThreadId;&lt;br /&gt;    hThread = CreateThread(NULL, 0, ServerThreadProc, NULL, 0, &amp;dwThreadId);&lt;br /&gt; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;void ShutEar() {&lt;br /&gt; shutdown(sock1, SD_BOTH); //0x02 is for both read &amp; write&lt;br /&gt; closesocket(sock1);&lt;br /&gt; shutdown(sock2, SD_BOTH); //0x02 is for both read &amp; write&lt;br /&gt; closesocket(sock2);&lt;br /&gt; CloseHandle(hThread);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;DWORD WINAPI ServerThreadProc( LPVOID lpParam ) {&lt;br /&gt; sock2 = accept(sock1, p_saddr2, &amp;sockaddr_len);&lt;br /&gt; char buf[256];&lt;br /&gt; &lt;br /&gt; strcpy(buf, "Hello\r\n"); // '\r' is carriage return; '\n' is line feed&lt;br /&gt; send(sock2, buf, strlen(buf), 0);&lt;br /&gt;&lt;br /&gt; return 0;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114594007778149082?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114594007778149082/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114594007778149082' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114594007778149082'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114594007778149082'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/04/socket-programming-in-win32.html' title='Socket Programming in Win32'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114369874785874267</id><published>2006-03-29T21:57:00.000-08:00</published><updated>2006-03-29T22:05:47.873-08:00</updated><title type='text'>Java</title><content type='html'>I know, you're probably wondering why an article on Java appears on a blog on Win32. Well, it's because Java can call native Win32 code using the JNI interface and I'm posting about my little experiment.&lt;br /&gt;&lt;br /&gt;I first created the Java source code like so:&lt;br /&gt;&lt;br /&gt;public class jennie {&lt;br /&gt;  private native void showMessage(String msg);&lt;br /&gt;  static {&lt;br /&gt;    System.loadLibrary("genie");&lt;br /&gt;    System.out.println("Library loaded");&lt;br /&gt;  }&lt;br /&gt;  public static void main(String[] args) {&lt;br /&gt;    jennie j = new jennie();&lt;br /&gt;    j.showMessage("Hola! These are 2 feet.");&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I then compiled the Java source code and used a utility called javah (provided with Sun JDK 1.5) and it generated the following code:&lt;br /&gt;&lt;br /&gt;/* DO NOT EDIT THIS FILE - it is machine generated */&lt;br /&gt;#include &lt;jni.h&gt;&lt;br /&gt;/* Header for class jennie */&lt;br /&gt;&lt;br /&gt;#ifndef _Included_jennie&lt;br /&gt;#define _Included_jennie&lt;br /&gt;#ifdef __cplusplus&lt;br /&gt;extern "C" {&lt;br /&gt;#endif&lt;br /&gt;/*&lt;br /&gt; * Class:     jennie&lt;br /&gt; * Method:    showMessage&lt;br /&gt; * Signature: (Ljava/lang/String;)V&lt;br /&gt; */&lt;br /&gt;JNIEXPORT void JNICALL Java_jennie_showMessage&lt;br /&gt;  (JNIEnv *, jobject, jstring);&lt;br /&gt;&lt;br /&gt;#ifdef __cplusplus&lt;br /&gt;}&lt;br /&gt;#endif&lt;br /&gt;#endif&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, I looked up the function prototype and created a method with the exact same name, and included a couple of header files (the jni.h header provided with JDK 1.5 and the javah generated header file, along with others that I call from my function). The resulting source code is like so:&lt;br /&gt;&lt;br /&gt;#include &lt;jni.h&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#include &lt;jennie.h&gt;&lt;br /&gt;&lt;br /&gt;JNIEXPORT void JNICALL Java_jennie_showMessage(JNIEnv* env, jobject, jstring jMsg) {&lt;br /&gt;  const char* msg=env-&gt;GetStringUTFChars(jMsg, 0);&lt;br /&gt;  printf("%s\n", msg);&lt;br /&gt;  env-&gt;ReleaseStringUTFChars(jMsg, msg);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Now, although it's pretty cool that you can call Win32 code from Java, it does look pretty ugly - just take a look at the function prototype and the string conversion!&lt;br /&gt;When it comes to communicating between Win32 and another development platforms, .NET should be your first choice since it's much cleaner (which is because they're both from Microsoft so they want you to stick to their products). There are a few restrictions on communicating between Unmanaged code (Win32) and Managed code so you'd probably want to get more details on it before you go exploring.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114369874785874267?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114369874785874267/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114369874785874267' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114369874785874267'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114369874785874267'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/03/java.html' title='Java'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114268323486468989</id><published>2006-03-15T04:00:00.000-08:00</published><updated>2009-01-09T07:05:50.499-08:00</updated><title type='text'>Who Am I?</title><content type='html'>Who Am I?&lt;br /&gt;&lt;br /&gt;#include &amp;lt;windows.h&amp;gt;&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;// Identify Windows Version&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;int __stdcall WinMain(HINSTANCE hPrevIntance, HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) {&lt;br /&gt; OSVERSIONINFO vi = { sizeof(OSVERSIONINFO) };&lt;br /&gt;&lt;br /&gt; // Versions&lt;br /&gt; //   VER_PLATFORM_WIN32_NT (PlatformId)&lt;br /&gt; //     (Major, Minor = Version)&lt;br /&gt; //     5, 0 = Windows 2000&lt;br /&gt; //     5, 1 = Windows XP&lt;br /&gt; //     5, 2 = Windows 2003&lt;br /&gt; //   VER_PLATFORM_WIN32_WINDOWS&lt;br /&gt; //     4, 0 = Windows 95&lt;br /&gt; //     4, 10 = Windows 98&lt;br /&gt; //     4, 90 = Windows ME&lt;br /&gt; //   VER_PLATFORM_WIN32s&lt;br /&gt; //     ???&lt;br /&gt; //&lt;br /&gt; // Additional Info is available using:&lt;br /&gt; //   ProductType: VER_NT_WORKSTATION, VER_NT_SERVER, VER_NT_DOMAIN_CONTROLLER&lt;br /&gt; //   wSuiteMask (Use '&amp;' with the constants and check the boolean result; Standard, if none match): &lt;br /&gt; //     VER_SUITE_PERSONAL, VER_SUITE_ENTERPRISE, VER_SUITE_BLADE, VER_SUITE_DATACENTER&lt;br /&gt;&lt;br /&gt; if (GetVersionEx(&amp;vi)) {&lt;br /&gt;  if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT) {&lt;br /&gt;   if (vi.dwMajorVersion==5 &amp;&amp; vi.dwMinorVersion==0)&lt;br /&gt;    MessageBoxA(NULL, "Running Windows 2000", "Info", MB_OK);&lt;br /&gt;   else if (vi.dwMajorVersion==5 &amp;&amp; vi.dwMinorVersion==1)&lt;br /&gt;    MessageBoxA(NULL, "Running Windows XP", "Info", MB_OK);&lt;br /&gt;   else if (vi.dwMajorVersion==5 &amp;&amp; vi.dwMinorVersion==2)&lt;br /&gt;    MessageBoxA(NULL, "Running Windows 2003", "Info", MB_OK);&lt;br /&gt;   else&lt;br /&gt;    MessageBoxA(NULL, "Unidentified Win32 NT class OS", "Info", MB_OK);&lt;br /&gt;  } else if (vi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {&lt;br /&gt;   if (vi.dwMajorVersion==4 &amp;&amp; vi.dwMinorVersion==0)&lt;br /&gt;    MessageBoxA(NULL, "Running Windows 95", "Info", MB_OK);&lt;br /&gt;   else if (vi.dwMajorVersion==4 &amp;&amp; vi.dwMinorVersion==10)&lt;br /&gt;    MessageBoxA(NULL, "Running Windows 98", "Info", MB_OK);&lt;br /&gt;   else if (vi.dwMajorVersion==4 &amp;&amp; vi.dwMinorVersion==90)&lt;br /&gt;    MessageBoxA(NULL, "Running Windows Millennium Edition", "Info", MB_OK);&lt;br /&gt;   else&lt;br /&gt;    MessageBoxA(NULL, "Unidentified Win32 non-NT class OS", "Info", MB_OK);&lt;br /&gt;  } else if (vi.dwPlatformId == VER_PLATFORM_WIN32s) {&lt;br /&gt;   MessageBoxA(NULL, "Unidentified Win32 class OS", "Info", MB_OK);&lt;br /&gt;  } else {&lt;br /&gt;   MessageBoxA(NULL, "Unidentified OS", "Info", MB_OK);&lt;br /&gt;  }&lt;br /&gt; } else {&lt;br /&gt;  MessageBoxA(NULL, "OS info not available!", "Error", MB_OK);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; return 0;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114268323486468989?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114268323486468989/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114268323486468989' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114268323486468989'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114268323486468989'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/03/who-am-i.html' title='Who Am I?'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114154381161483506</id><published>2006-03-04T23:29:00.000-08:00</published><updated>2006-03-04T23:30:11.630-08:00</updated><title type='text'>Minimize to Tray for Win32 64-bit</title><content type='html'>//I just got SetWindowLongPtr working, so here's the new code for 'Minimize to tray'.&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;// MINIMIZE TO TRAY&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;NOTIFYICONDATA nid;&lt;br /&gt;bool isTrayIcon=false;&lt;br /&gt;&lt;br /&gt;LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {&lt;br /&gt; switch (msg) {&lt;br /&gt;  case 10101:&lt;br /&gt;   if (lParam == WM_LBUTTONDBLCLK) {&lt;br /&gt;    OpenIcon(hwnd);&lt;br /&gt;&lt;br /&gt;//    SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, NULL);&lt;br /&gt;//    SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELPARAM(320, 200));&lt;br /&gt;//    SetForegroundWindow(hwnd);&lt;br /&gt;//    SetActiveWindow(hwnd);&lt;br /&gt;//    ShowWindow(hwnd, SW_SHOW);&lt;br /&gt;//    UpdateWindow(hwnd);&lt;br /&gt;//    SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE  | SWP_NOREPOSITION | SWP_SHOWWINDOW);&lt;br /&gt;   }&lt;br /&gt;   break;&lt;br /&gt;  case WM_SIZE:&lt;br /&gt;&lt;br /&gt;   if (wParam == SIZE_MINIMIZED) {&lt;br /&gt;    //Set tray icon here&lt;br /&gt;&lt;br /&gt;    nid.cbSize=sizeof(NOTIFYICONDATA);&lt;br /&gt;    nid.hWnd = hwnd;&lt;br /&gt;    nid.hIcon = LoadIcon(NULL, IDI_APPLICATION);&lt;br /&gt;    nid.szTip[0] = 'T'; nid.szTip[1] = 'V'; nid.szTip[2] = '\0';&lt;br /&gt;    nid.uID = 1;&lt;br /&gt;    nid.uCallbackMessage = 10101;&lt;br /&gt;    nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;&lt;br /&gt; &lt;br /&gt;    Shell_NotifyIcon(NIM_ADD, &amp;nid);&lt;br /&gt;&lt;br /&gt;    ShowWindow(hwnd, SW_HIDE);&lt;br /&gt;//    SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);&lt;br /&gt;    SetWindowLongPtr(hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);&lt;br /&gt;    ShowWindow(hwnd, SW_SHOW);&lt;br /&gt;&lt;br /&gt;    isTrayIcon=true;&lt;br /&gt;   } else {&lt;br /&gt;    //Remove tray icon here&lt;br /&gt;    if (isTrayIcon) {&lt;br /&gt;     Shell_NotifyIcon(NIM_DELETE, &amp;nid);&lt;br /&gt;&lt;br /&gt;     ShowWindow(hwnd, SW_HIDE);&lt;br /&gt;     SetWindowLongPtr(hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW);&lt;br /&gt;//     SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW);&lt;br /&gt;     ShowWindow(hwnd, SW_SHOW);&lt;br /&gt;&lt;br /&gt;     isTrayIcon=false;&lt;br /&gt;    }&lt;br /&gt;   }&lt;br /&gt;   break;&lt;br /&gt;  case WM_CLOSE:&lt;br /&gt;   DestroyWindow(hwnd);&lt;br /&gt;   break;&lt;br /&gt;  case WM_DESTROY:&lt;br /&gt;   PostQuitMessage(0);&lt;br /&gt;   break;&lt;br /&gt;  default:&lt;br /&gt;   return DefWindowProc(hwnd, msg, wParam, lParam);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int __stdcall WinMain(HINSTANCE hPrevInstance, HINSTANCE hInstance, LPSTR CmdLine, int nCmdShow) {&lt;br /&gt;&lt;br /&gt; WNDCLASSEX wc;&lt;br /&gt; int ret=0;&lt;br /&gt;&lt;br /&gt; wc.cbClsExtra=sizeof(LONG);&lt;br /&gt; wc.cbSize=sizeof(WNDCLASSEX);&lt;br /&gt; wc.cbWndExtra=sizeof(LONG);&lt;br /&gt; wc.hbrBackground=(HBRUSH) (COLOR_WINDOW+1);&lt;br /&gt; wc.hCursor=LoadCursor(NULL, IDC_ARROW);&lt;br /&gt; wc.hIcon=LoadIcon(NULL, IDI_APPLICATION);&lt;br /&gt; wc.hIconSm=LoadIcon(NULL, IDI_APPLICATION);&lt;br /&gt; wc.hInstance=hInstance;&lt;br /&gt; wc.lpfnWndProc=WndProc;&lt;br /&gt; wc.lpszClassName="Marshal";&lt;br /&gt; wc.lpszMenuName=NULL;&lt;br /&gt; wc.style=0;&lt;br /&gt;&lt;br /&gt; ret = RegisterClassExA(&amp;wc);&lt;br /&gt; if (ret==0) {&lt;br /&gt;  MessageBoxA(NULL, "Could not register window class", "Error", MB_OK);&lt;br /&gt;  ExitProcess(-1);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; HWND hwnd;&lt;br /&gt; hwnd = CreateWindowEx(0, "Marshal", "Video Game", WS_OVERLAPPEDWINDOW, 10, 10, 320, 200, NULL, NULL, hInstance, NULL);&lt;br /&gt;&lt;br /&gt; if (hwnd==NULL) {&lt;br /&gt;  MessageBoxA(NULL, "Could not instantiate window class", "Error", MB_OK);&lt;br /&gt;  ExitProcess(-1);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; ShowWindow(hwnd, nCmdShow);&lt;br /&gt; UpdateWindow(hwnd);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; MSG msg;&lt;br /&gt; while (GetMessage(&amp;msg, NULL, 0, 0)&gt;0) {&lt;br /&gt;  TranslateMessage(&amp;msg);&lt;br /&gt;  DispatchMessage(&amp;msg);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; return (int) msg.wParam;&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114154381161483506?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114154381161483506/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114154381161483506' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114154381161483506'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114154381161483506'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/03/minimize-to-tray-for-win32-64-bit.html' title='Minimize to Tray for Win32 64-bit'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114153919866600330</id><published>2006-03-04T22:13:00.000-08:00</published><updated>2006-03-04T22:13:18.666-08:00</updated><title type='text'>Abraca-Da-Minimo</title><content type='html'>//&lt;br /&gt;// MINIMIZE TO TRAY&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;NOTIFYICONDATA nid;&lt;br /&gt;bool isTrayIcon=false;&lt;br /&gt;&lt;br /&gt;LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {&lt;br /&gt; switch (msg) {&lt;br /&gt;  case 10101:&lt;br /&gt;   if (lParam == WM_LBUTTONDBLCLK) {&lt;br /&gt;    OpenIcon(hwnd);&lt;br /&gt;&lt;br /&gt;//    SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, NULL);&lt;br /&gt;//    SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELPARAM(320, 200));&lt;br /&gt;//    SetForegroundWindow(hwnd);&lt;br /&gt;//    SetActiveWindow(hwnd);&lt;br /&gt;//    ShowWindow(hwnd, SW_SHOW);&lt;br /&gt;//    UpdateWindow(hwnd);&lt;br /&gt;//    SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE  | SWP_NOREPOSITION | SWP_SHOWWINDOW);&lt;br /&gt;   }&lt;br /&gt;   break;&lt;br /&gt;  case WM_SIZE:&lt;br /&gt;&lt;br /&gt;   if (wParam == SIZE_MINIMIZED) {&lt;br /&gt;    //Set tray icon here&lt;br /&gt;&lt;br /&gt;    nid.cbSize=sizeof(NOTIFYICONDATA);&lt;br /&gt;    nid.hWnd = hwnd;&lt;br /&gt;    nid.hIcon = LoadIcon(NULL, IDI_APPLICATION);&lt;br /&gt;    nid.szTip[0] = 'T'; nid.szTip[1] = 'V'; nid.szTip[2] = '\0';&lt;br /&gt;    nid.uID = 1;&lt;br /&gt;    nid.uCallbackMessage = 10101;&lt;br /&gt;    nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;&lt;br /&gt; &lt;br /&gt;    Shell_NotifyIcon(NIM_ADD, &amp;nid);&lt;br /&gt;&lt;br /&gt;    LONG toolWindowExStyle = WS_EX_TOOLWINDOW;&lt;br /&gt;    ShowWindow(hwnd, SW_HIDE);&lt;br /&gt;    SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);&lt;br /&gt;//    SetWindowLongPtr(hwnd, GWL_EXSTYLE, (LONG_PTR) &amp;toolWindowExStyle);&lt;br /&gt;    ShowWindow(hwnd, SW_SHOW);&lt;br /&gt;&lt;br /&gt;    isTrayIcon=true;&lt;br /&gt;   } else {&lt;br /&gt;    //Remove tray icon here&lt;br /&gt;    if (isTrayIcon) {&lt;br /&gt;     Shell_NotifyIcon(NIM_DELETE, &amp;nid);&lt;br /&gt;&lt;br /&gt;     LONG appWindowExStyle = WS_EX_APPWINDOW;&lt;br /&gt;     ShowWindow(hwnd, SW_HIDE);&lt;br /&gt;//     SetWindowLongPtr(hwnd, GWL_EXSTYLE, (LONG_PTR) &amp;appWindowExStyle);&lt;br /&gt;     SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW);&lt;br /&gt;     ShowWindow(hwnd, SW_SHOW);&lt;br /&gt;&lt;br /&gt;     isTrayIcon=false;&lt;br /&gt;    }&lt;br /&gt;   }&lt;br /&gt;   break;&lt;br /&gt;  case WM_CLOSE:&lt;br /&gt;   DestroyWindow(hwnd);&lt;br /&gt;   break;&lt;br /&gt;  case WM_DESTROY:&lt;br /&gt;   PostQuitMessage(0);&lt;br /&gt;   break;&lt;br /&gt;  default:&lt;br /&gt;   return DefWindowProc(hwnd, msg, wParam, lParam);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int __stdcall WinMain(HINSTANCE hPrevInstance, HINSTANCE hInstance, LPSTR CmdLine, int nCmdShow) {&lt;br /&gt;&lt;br /&gt; WNDCLASSEX wc;&lt;br /&gt; int ret=0;&lt;br /&gt;&lt;br /&gt; wc.cbClsExtra=0;&lt;br /&gt; wc.cbSize=sizeof(WNDCLASSEX);&lt;br /&gt; wc.cbWndExtra=0;&lt;br /&gt; wc.hbrBackground=(HBRUSH) (COLOR_WINDOW+1);&lt;br /&gt; wc.hCursor=LoadCursor(NULL, IDC_ARROW);&lt;br /&gt; wc.hIcon=LoadIcon(NULL, IDI_APPLICATION);&lt;br /&gt; wc.hIconSm=LoadIcon(NULL, IDI_APPLICATION);&lt;br /&gt; wc.hInstance=hInstance;&lt;br /&gt; wc.lpfnWndProc=WndProc;&lt;br /&gt; wc.lpszClassName="Marshal";&lt;br /&gt; wc.lpszMenuName=NULL;&lt;br /&gt; wc.style=0;&lt;br /&gt;&lt;br /&gt; ret = RegisterClassExA(&amp;wc);&lt;br /&gt; if (ret==0) {&lt;br /&gt;  MessageBoxA(NULL, "Could not register window class", "Error", MB_OK);&lt;br /&gt;  ExitProcess(-1);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; HWND hwnd;&lt;br /&gt; hwnd = CreateWindowEx(0, "Marshal", "Video Game", WS_OVERLAPPEDWINDOW, 10, 10, 320, 200, NULL, NULL, hInstance, NULL);&lt;br /&gt;&lt;br /&gt; if (hwnd==NULL) {&lt;br /&gt;  MessageBoxA(NULL, "Could not instantiate window class", "Error", MB_OK);&lt;br /&gt;  ExitProcess(-1);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; ShowWindow(hwnd, nCmdShow);&lt;br /&gt; UpdateWindow(hwnd);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; MSG msg;&lt;br /&gt; while (GetMessage(&amp;msg, NULL, 0, 0)&gt;0) {&lt;br /&gt;  TranslateMessage(&amp;msg);&lt;br /&gt;  DispatchMessage(&amp;msg);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; return (int) msg.wParam;&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114153919866600330?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114153919866600330/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114153919866600330' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114153919866600330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114153919866600330'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/03/abraca-da-minimo.html' title='Abraca-Da-Minimo'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114153909556220270</id><published>2006-03-04T22:11:00.000-08:00</published><updated>2006-03-04T22:11:35.570-08:00</updated><title type='text'>64 is twice 32... that's twice as hard</title><content type='html'>The MSDN documentation says that SetWindowLong is deprecated (it didn't use that exact word) and should be replaced with SetWindowLongPtr instead to work with 64-bit versions of Windows. I thought I'd try it out and did the following:&lt;br /&gt;&lt;br /&gt;LONG appWindowExStyle = WS_EX_APPWINDOW;&lt;br /&gt;SetWindowLongPtr(hwnd, GWL_EXSTYLE, (LONG_PTR) &amp;appWindowExStyle);&lt;br /&gt;&lt;br /&gt;It didn't seem to work. However, the old 32-bit way seems to work fine:&lt;br /&gt;&lt;br /&gt;SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW);&lt;br /&gt;&lt;br /&gt;I guess it's one of those things that I ought to investigate further.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114153909556220270?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114153909556220270/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114153909556220270' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114153909556220270'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114153909556220270'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/03/64-is-twice-32-thats-twice-as-hard.html' title='64 is twice 32... that&apos;s twice as hard'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114138328654964736</id><published>2006-03-02T02:54:00.000-08:00</published><updated>2006-03-03T02:54:46.550-08:00</updated><title type='text'>Changing Window Attributes</title><content type='html'>When you register a window class or create a window, you get to specify window attributes, however once your window is running, you may wish to change the window's attributes to do something like removing the taskbar button for a window on minimizing (used in the 'Minimize to tray' feature of applications). This can be done using SetWindowLongPtr (SetWindowLong can be used too, but it will not work on 64-bit versions of Windows).&lt;br /&gt;&lt;br /&gt;I've read some time back in an MSDN article that the window has to be hidden/disabled (I can't remember which... my guess would be hidden) before the attribute is changed. I'll try it and post the code for it sometime soon.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114138328654964736?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114138328654964736/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114138328654964736' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114138328654964736'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114138328654964736'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/03/changing-window-attributes.html' title='Changing Window Attributes'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114138325479755214</id><published>2006-03-01T02:53:00.000-08:00</published><updated>2006-03-03T02:54:14.796-08:00</updated><title type='text'>VC++ programs in BC++</title><content type='html'>To get your Visual C++ programs to run in Borland C++, you'll have to devise some means to call the WinMain method. The following is a method that can do this for you:&lt;br /&gt;&lt;br /&gt;int main() {&lt;br /&gt; HINSTANCE hInstance = GetModuleHandle(NULL);&lt;br /&gt; LPSTR CmdLine = GetCommandLine();&lt;br /&gt; int ret = WinMain(hInstance, NULL, CmdLine, SW_SHOWDEFAULT);&lt;br /&gt; ExitProcess(ret);&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114138325479755214?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114138325479755214/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114138325479755214' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114138325479755214'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114138325479755214'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/03/vc-programs-in-bc.html' title='VC++ programs in BC++'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114138323150622995</id><published>2006-02-26T02:53:00.000-08:00</published><updated>2006-03-03T02:53:51.506-08:00</updated><title type='text'>Creating a Tray Icon</title><content type='html'>#undef UNICODE&lt;br /&gt;#undef _UNICODE&lt;br /&gt;#include &lt;windows.h&gt;&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;// TRAY ICON&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;NOTIFYICONDATA nid;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {&lt;br /&gt; switch (msg) {&lt;br /&gt;  case 10101:&lt;br /&gt;   if (lParam == WM_LBUTTONDBLCLK) {&lt;br /&gt;    MessageBoxA(NULL, "Hello", "Hi", MB_OK);&lt;br /&gt;   }&lt;br /&gt;   break;&lt;br /&gt;  case WM_CREATE:&lt;br /&gt;   break;&lt;br /&gt;  case WM_CLOSE:&lt;br /&gt;   DestroyWindow(hwnd);&lt;br /&gt;   break;&lt;br /&gt;  case WM_DESTROY:&lt;br /&gt;   PostQuitMessage(0);&lt;br /&gt;   break;&lt;br /&gt;  default:&lt;br /&gt;   return DefWindowProc(hwnd, msg, wParam, lParam);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int __stdcall WinMain(HINSTANCE hPrevInstance, HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow) {&lt;br /&gt; WNDCLASSEX wc;&lt;br /&gt; int ret;&lt;br /&gt; MSG msg;&lt;br /&gt; HWND hwnd;&lt;br /&gt;&lt;br /&gt; wc.cbClsExtra=0;&lt;br /&gt; wc.cbSize=sizeof(WNDCLASSEX);&lt;br /&gt; wc.cbWndExtra=0;&lt;br /&gt; wc.hbrBackground=(HBRUSH) (COLOR_WINDOW+1);&lt;br /&gt; wc.hCursor=LoadCursor(NULL, IDC_ARROW);&lt;br /&gt; wc.hIcon=wc.hIconSm=LoadIcon(NULL, IDI_APPLICATION);&lt;br /&gt; wc.hInstance=hInstance;&lt;br /&gt; wc.lpfnWndProc=WndProc;&lt;br /&gt; wc.lpszClassName="Cyto";&lt;br /&gt; wc.lpszMenuName=NULL;&lt;br /&gt; wc.style=0;&lt;br /&gt;&lt;br /&gt; ret = RegisterClassEx(&amp;wc);&lt;br /&gt; if (ret==NULL) {&lt;br /&gt;  MessageBoxA(NULL, "Could not register window", "Error", MB_OK);&lt;br /&gt;  ExitProcess(-1);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; hwnd = CreateWindowEx(NULL, "Cyto", "The League", WS_OVERLAPPEDWINDOW, 10, 10, 320, 200, NULL, NULL, hInstance, NULL);&lt;br /&gt; if (hwnd==NULL) {&lt;br /&gt;  MessageBoxA(NULL, "Could not create window", "Error", MB_OK);&lt;br /&gt;  ExitProcess(-1);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; ShowWindow(hwnd, nCmdShow);&lt;br /&gt; UpdateWindow(hwnd);&lt;br /&gt;&lt;br /&gt; nid.cbSize=sizeof(NOTIFYICONDATA);&lt;br /&gt; nid.hWnd = hwnd;&lt;br /&gt; nid.hIcon = LoadIcon(NULL, IDI_APPLICATION);&lt;br /&gt; nid.szTip[0] = 'T'; nid.szTip[1] = 'V'; nid.szTip[2] = '\0';&lt;br /&gt; nid.uID = 1;&lt;br /&gt; nid.uCallbackMessage = 10101;&lt;br /&gt; nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;&lt;br /&gt; &lt;br /&gt; Shell_NotifyIcon(NIM_ADD, &amp;nid);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; while (GetMessage(&amp;msg, hwnd, 0, 0)&gt;0) {&lt;br /&gt;  TranslateMessage(&amp;msg);&lt;br /&gt;  DispatchMessage(&amp;msg);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; Shell_NotifyIcon(NIM_DELETE, &amp;nid);&lt;br /&gt;&lt;br /&gt; return (int) msg.wParam;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114138323150622995?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114138323150622995/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114138323150622995' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114138323150622995'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114138323150622995'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/02/creating-tray-icon.html' title='Creating a Tray Icon'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114138320248686380</id><published>2006-02-26T02:52:00.000-08:00</published><updated>2006-03-03T02:53:22.486-08:00</updated><title type='text'>Window with Controls</title><content type='html'>Controls are just like windows - You create them with CreateWindowEx and get an HWND on creation.&lt;br /&gt;&lt;br /&gt;#undef UNICODE&lt;br /&gt;#undef _UNICODE&lt;br /&gt;#include &lt;windows.h&gt;&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;// SIMPLE CONTROLS&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {&lt;br /&gt; switch (msg) {&lt;br /&gt;  case WM_COMMAND:&lt;br /&gt;   if (wParam==2) {&lt;br /&gt;    HWND target_hwnd = FindWindowEx(NULL, NULL, NULL, "My Computer");&lt;br /&gt;    if (target_hwnd==NULL) {&lt;br /&gt;     MessageBoxA(NULL, "FindWindow error", "Error", MB_OK);&lt;br /&gt;    } else {&lt;br /&gt;&lt;br /&gt;//     MoveWindow(target_hwnd, 50, 50, 320, 200, TRUE);&lt;br /&gt;    }&lt;br /&gt;   }&lt;br /&gt;   break;&lt;br /&gt;  case WM_CREATE:&lt;br /&gt;  //Use "edit" for textbox and "button" for command button; the hmenu value will appear as wParam with a WM_COMMAND message on clicking&lt;br /&gt;   CreateWindowEx(NULL, "button", "Click", WS_VISIBLE|WS_CHILD|WS_BORDER, 30, 30, 75, 30, hwnd, (HMENU) 2, NULL, NULL);&lt;br /&gt;   break;&lt;br /&gt;  case WM_CLOSE:&lt;br /&gt;   DestroyWindow(hwnd);&lt;br /&gt;   break;&lt;br /&gt;  case WM_DESTROY:&lt;br /&gt;   PostQuitMessage(0);&lt;br /&gt;   break;&lt;br /&gt;  default:&lt;br /&gt;   return DefWindowProc(hwnd, msg, wParam, lParam);&lt;br /&gt; }&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int __stdcall WinMain(HINSTANCE hPrevInstance, HINSTANCE hInstance, LPSTR CmdLine, int nCmdShow) {&lt;br /&gt; WNDCLASSEX wc;&lt;br /&gt; int ret=0;&lt;br /&gt; HWND hwnd;&lt;br /&gt; MSG msg;&lt;br /&gt;&lt;br /&gt; wc.cbClsExtra=0;&lt;br /&gt; wc.cbSize=sizeof(WNDCLASSEX);&lt;br /&gt; wc.cbWndExtra=0;&lt;br /&gt; wc.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);&lt;br /&gt; wc.hCursor=LoadCursor(NULL, IDC_ARROW);&lt;br /&gt; wc.hIcon=(wc.hIconSm=LoadIcon(NULL, IDI_APPLICATION));&lt;br /&gt; wc.hInstance=hInstance;&lt;br /&gt; wc.lpfnWndProc=WndProc;&lt;br /&gt; wc.lpszClassName="Mariott";&lt;br /&gt; wc.lpszMenuName=NULL;&lt;br /&gt; wc.style=0;&lt;br /&gt;&lt;br /&gt; if ((ret=RegisterClassExA(&amp;wc))==0) ExitProcess(-1);&lt;br /&gt;&lt;br /&gt; if ((hwnd = CreateWindowEx(0, "Mariott", "White Wine", WS_OVERLAPPEDWINDOW, 10, 10, 320, 200, NULL, NULL, hInstance, NULL))==NULL) ExitProcess(-1);&lt;br /&gt; ShowWindow(hwnd, nCmdShow);&lt;br /&gt; UpdateWindow(hwnd);&lt;br /&gt; &lt;br /&gt; while (GetMessage(&amp;msg, hwnd, 0, 0)&gt;0) {&lt;br /&gt;  TranslateMessage(&amp;msg);&lt;br /&gt;  DispatchMessage(&amp;msg);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; return (int) msg.wParam;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114138320248686380?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114138320248686380/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114138320248686380' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114138320248686380'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114138320248686380'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/02/window-with-controls.html' title='Window with Controls'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114138312568433945</id><published>2006-02-26T02:51:00.001-08:00</published><updated>2006-03-03T02:52:05.686-08:00</updated><title type='text'>Simple Win32 Window</title><content type='html'>#undef UNICODE&lt;br /&gt;#undef _UNICODE&lt;br /&gt;#include &lt;windows.h&gt;&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;// SIMPLE WINDOW&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {&lt;br /&gt; switch (msg) {&lt;br /&gt;  case WM_CLOSE:&lt;br /&gt;   DestroyWindow(hwnd);&lt;br /&gt;   break;&lt;br /&gt;  case WM_DESTROY:&lt;br /&gt;   PostQuitMessage(0);&lt;br /&gt;   break;&lt;br /&gt;  default:&lt;br /&gt;   return DefWindowProc(hwnd, msg, wParam, lParam);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int __stdcall WinMain(HINSTANCE hPrevInstance, HINSTANCE hInstance, LPSTR CmdLine, int nCmdShow) {&lt;br /&gt;&lt;br /&gt; WNDCLASSEX wc;&lt;br /&gt; int ret=0;&lt;br /&gt;&lt;br /&gt; wc.cbClsExtra=0;&lt;br /&gt; wc.cbSize=sizeof(WNDCLASSEX);&lt;br /&gt; wc.cbWndExtra=0;&lt;br /&gt; wc.hbrBackground=(HBRUSH) (COLOR_WINDOW+1);&lt;br /&gt; wc.hCursor=LoadCursor(NULL, IDC_ARROW);&lt;br /&gt; wc.hIcon=LoadIcon(NULL, IDI_APPLICATION);&lt;br /&gt; wc.hIconSm=LoadIcon(NULL, IDI_APPLICATION);&lt;br /&gt; wc.hInstance=hInstance;&lt;br /&gt; wc.lpfnWndProc=WndProc;&lt;br /&gt; wc.lpszClassName="Marshal";&lt;br /&gt; wc.lpszMenuName=NULL;&lt;br /&gt; wc.style=0;&lt;br /&gt;&lt;br /&gt; ret = RegisterClassExA(&amp;wc);&lt;br /&gt; if (ret==0) {&lt;br /&gt;  MessageBoxA(NULL, "Could not register window class", "Error", MB_OK);&lt;br /&gt;  ExitProcess(-1);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; HWND hwnd;&lt;br /&gt; hwnd = CreateWindowEx(0, "Marshal", "Video Game", WS_OVERLAPPEDWINDOW, 10, 10, 320, 200, NULL, NULL, hInstance, NULL);&lt;br /&gt;&lt;br /&gt; if (hwnd==NULL) {&lt;br /&gt;  MessageBoxA(NULL, "Could not instantiate window class", "Error", MB_OK);&lt;br /&gt;  ExitProcess(-1);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; ShowWindow(hwnd, nCmdShow);&lt;br /&gt; UpdateWindow(hwnd);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; MSG msg;&lt;br /&gt; while (GetMessage(&amp;msg, NULL, 0, 0)&gt;0) {&lt;br /&gt;  TranslateMessage(&amp;msg);&lt;br /&gt;  DispatchMessage(&amp;msg);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; return (int) msg.wParam;&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114138312568433945?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114138312568433945/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114138312568433945' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114138312568433945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114138312568433945'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/02/simple-win32-window.html' title='Simple Win32 Window'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114138308359369718</id><published>2006-02-26T02:51:00.000-08:00</published><updated>2006-03-03T02:51:23.593-08:00</updated><title type='text'>Single Instance Application</title><content type='html'>Mutexes (Mutual Exclusion Locks; I believe it is also known as a spin-lock) are used to control access to shared resources. They can also be used in Windows Applications to ensure that only one instance of an application runs at any given time.&lt;br /&gt;&lt;br /&gt;The following is an example of using a mutex in a simple Win32 application:&lt;br /&gt;&lt;br /&gt;#undef UNICODE&lt;br /&gt;#undef _UNICODE&lt;br /&gt;#include &lt;windows.h&gt;&lt;br /&gt;&lt;br /&gt;//&lt;br /&gt;// SINGLE INSTANCE USING MUTEX&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;int __stdcall WinMain(HINSTANCE hPrevInstance, HINSTANCE hInstance, LPSTR CmdLine, int nCmdShow) {&lt;br /&gt; HANDLE hMutex;&lt;br /&gt; hMutex = CreateMutexA(NULL, FALSE, "VoilaApp");&lt;br /&gt;&lt;br /&gt; if (GetLastError()==ERROR_ALREADY_EXISTS) {&lt;br /&gt;  MessageBoxA (NULL, "Error", "Already running", MB_OK);&lt;br /&gt;  ExitProcess(-1);&lt;br /&gt; }&lt;br /&gt; MessageBoxA (NULL, "Voila", "It's working", MB_OK);&lt;br /&gt; return 0;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114138308359369718?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114138308359369718/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114138308359369718' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114138308359369718'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114138308359369718'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/02/single-instance-application.html' title='Single Instance Application'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-23341943.post-114138305326935451</id><published>2006-02-26T02:50:00.000-08:00</published><updated>2006-03-03T02:50:53.280-08:00</updated><title type='text'>Introduction</title><content type='html'>This blog is an attempt to put together little articles &amp; snippets of Win32 C++ code that can be used as examples for beginners. In the process, I hope to become more proficient in Win32 as well since, at the moment, I'm just a novice.&lt;br /&gt;&lt;br /&gt;With Visual C++ .NET, writing Win32 applications is easier than ever. You can write all of your logic in a higher language such as VB.NET, C# or J#; all the Windows low-level stuff can be written in C++ libraries. It'll also ensure that you don't have to throw away your C++ code anytime in the near future as Microsoft intends to keep C++ developers employed for many more years to come.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/23341943-114138305326935451?l=win32-api.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://win32-api.blogspot.com/feeds/114138305326935451/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=23341943&amp;postID=114138305326935451' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114138305326935451'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/23341943/posts/default/114138305326935451'/><link rel='alternate' type='text/html' href='http://win32-api.blogspot.com/2006/02/introduction.html' title='Introduction'/><author><name>Nitin Reddy Katkam</name><uri>http://www.blogger.com/profile/09612217398194148324</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://2.bp.blogspot.com/_Vel48i2U1Yg/SUkxX5ePzKI/AAAAAAAAAGc/cNTDMVaNLKY/S220/03062008(003).jpg'/></author><thr:total>0</thr:total></entry></feed>
