Search Results

Search found 746 results on 30 pages for 'winapi'.

Page 24/30 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30  | Next Page >

  • Get the selected file in an Explorer window

    - by Jon Fournier
    I'd like to know how, if possible, to get the path of the selected file in an open Windows Explorer window. If not, would it at least be possible to get the folder path of an open Windows Explorer window? The end reason I'm doing this, is a software tool I'm writing requires a user to select a file. I figure if they're already moving the file around with Windows Explorer and then start my tool up, it'd be good not to have to make them navigate to the folder again in the file open dialog box. My software would then be able to identify if it's got the right file extension and if so, just ask the user if they want to import that file. Thanks.

    Read the article

  • Unicode string handling using Windows API

    - by DeadMG
    I always assumed that Unicode string handling was some dark art. However, I've seen that the Windows API has functions for comparing Unicode strings, for example. Does that mean that it's actually feasible to write a Unicode string class that can perform simple actions like sorting, equality comparison, and extraction from a file? Or are there hidden gotchas in the use of these functions that makes it actually a really bad idea? I'm just looking at libraries like ICU and they seem incredibly over-complicated compared to what a Unicode string class backed by the Windows API could actually look like, which would resemble the Standard string classes quite closely.

    Read the article

  • C++ - Creating folder method

    - by Matthew
    I have the following method in C++: void create_folder(LPCWSTR full_folder) //Method to create folder in case it does not exist { if(!CreateDirectory(full_folder,attr)) //Checking whether the folder already exists { switch (GetLastError()) { case ERROR_ALREADY_EXISTS: printf("The folder already exists!\n\n"); break; case NULL: printf("The folder does not exist!\n\n"); printf("The folder was created successfully!\n\n"); break; } } } In case the folder already exists, the correct message is displayed on the screen. However, if the folder does NOT exist, nothing is displayed on the screen, that is, the part identified by case NULL is not executed. How can I solve this problem? In other words, how can I get the code after the case NULL to run if the folder does not exist?

    Read the article

  • Programatically determining file "size on disk" in advance

    - by porkchop
    I need to know how big a given in-memory buffer will be as an on-disk (usb stick) file before I write it. I know that unless the size falls on the block size boundary, its likely to get rounded up, e.g. a 1 byte file takes up 4096 bytes on-disk. I'm currently doing this using GetDiskFreeSpace() to work out the disk block size, then using this to calculate the on-disk size like this: GetDiskFreeSpace(szDrive, &dwSectorsPerCluster, &dwBytesPerSector, NULL, NULL); dwBlockSize = dwSectorsPerCuster * dwBytesPerSector; if (dwInMemorySize % dwBlockSize != 0) { dwSizeOnDisk = ((dwInMemorySize / dwBlockSize) * dwBlockSize) + dwBlockSize; } else { dwSizeOnDisk = dwInMemorySize; } Which seems to work fine, BUT GetDiskFreeSpace() only works on disks up to 2GB according to MSDN. GetDiskFreeSpaceEx() doesn't return the same information, so my question is, how else can I calculate this information for drives 2GB? Is there an API call I've missed? Can I assume some hard values depending on the overall disk size?

    Read the article

  • Clicking mouse by sending messages

    - by Frank Meulenaar
    I'm trying to send mouse clicks to a program. As I don't want the mouse to move, I don't want to use SendInput or mouse_event, and because the window that should receive the clicks doesn't really use Buttons or other GUI events, I can't send messages to these buttons. I'm trying to get this working using SendMessage, but for some reason it doesn't work. Relevant code is (in C#, but tried Java with jnative as well), trying this on Vista [DllImport("user32.dll", CharSet=CharSet.Auto)] public static extern int SendMessage(IntPtr A_0, int A_1, int A_2, int A_3); static int WM_CLOSE = 0x10; static int WM_LBUTTONDOWN = 0x201; static int WM_LBUTTONUP = 0x202; public static void click(IntPtr hWnd, int x, int y) { SendMessage(hWnd, WM_LBUTTONDOWN, 1, ((x << 0x10) ^ y)); SendMessage(hWnd, WM_LBUTTONUP, 0, ((x << 0x10) ^ y)); } public static void close(IntPtr hWnd) { SendMessage(hWnd, WM_CLOSE, 0, 0); } The close works fine, but the click doesn't do anything.

    Read the article

  • how to make text appear when you hover at a particular area?

    - by Michael
    I'm mainly using c++ win32 API project and the question is asked keeping in mind: When you use microsoft visual studio 2010 visual c++ editor and you minimize any function, then ahead of the function you get a box; hovering over which you see the entire function. How to implement this in c++ win32 API ? for ex- when a win32 project is created in vs2010, and empty project checkbox is unchecked then by default you get a code which after running produces a window which has a menu bar containing File an Help. Now i want some text to come when i hover over each of them. I do not want a code just a hint how it can be done. Thanks in advance.

    Read the article

  • Define thread in C++

    - by Vsevywniy
    How do I start a thread using _beginthreadex(), making it execute void myFunction(wchar_t *param);? I try to use this: _beginthread(NULL, 0, myFunction, L"someParam", 0, &ThreadID); but there is compilation error: error C2664: 'beginthreadex' : cannot convert parameter 3 from 'void (_cdecl *)(wchar_t *)' to 'unsigned int (__stdcall *)(void *)'. How I can resolve this error? I seem able to do _beginthread((void(*)(void*))myFunction, 0 , (void *)L"someParam");. But for _beginthreadex() these casts don't seem to work. What do I need to do?

    Read the article

  • How can I create a menu in the start menu for my program?

    - by Joe
    This may be an easy question but I am not even sure of the terminology to search, so I have to ask. I want my program to have a menu when it is hovered over if it is pinned to the start menu. I am attaching a screenshot where windows powershell illustrates this function, and presents a list of tasks. Other programs sometimes use this to list recently opened files, etc. I am sure this is standard enough that there is a tutorial on it somewhere, would someone mind pointing me to it, or explaining how to do this? I hope that it doesn't matter too much what language is used, but I am proficient in Delphi, C++, and C#.

    Read the article

  • ValidateRect vs BeginPaint

    - by Armentage
    From the MSDN documentation: The BeginPaint function validates the entire client area. The ValidateRect function should not be called if a portion of the update region must be validated before the next WM_PAINT message is generated.1 I've been programming with Win32 API for years, and I've never thought to call the ValidateRect function. A co-worker of mine today pointed that we were missing a call to ValidateRect, which fixed a bug we were having doing some high-speed animation using GDI (I know, an oxymoron) Can someone tell me whether or not a call to ValidateRect is neccessary after a BeginPaint/EndPaint pair? I have seen no documentation at MSDN that sheds light on this, and what documentation and examples I do see that you do not need to.

    Read the article

  • How can I check the network connection type using the Windows API?

    - by Jufkey
    How can I programmatically retrieve the current connection type (eg. LAN or Direct connection)? InternetGetConnectedState() isn't very reliable. For instance, I'm connected to a wireless network, but ConTypeRet is 18, which is INTERNET_CONNECTION_LAN & INTERNET_RAS_INSTALLED. Isn't there any way to make sure that ConTypeRet is either INTERNET_CONNECTION_LAN or INTERNET_CONNECTION_MODEM?

    Read the article

  • WIN32 visual c++

    - by mrbuxley
    I would like to write a simple program in c++. After the program is done i would like to get my answers in form of a graph or picture that would give some certain information if i click on a certain area. i have only written console apllications in c++ before and don't really have a clue where to start with the graphic part of it all. Can I write the first part of the program in console mode and some how run it under the WIN32 later? for ex what will happen to the cout<<"foo"; commands? Is there a simpler approach to do some very basic graphic programming.

    Read the article

  • Does SetThreadPriority cause thread reschedulling?

    - by Suma
    Consider following situation, assuming single CPU system: thread A is running with a priority THREAD_PRIORITY_NORMAL, signals event E thread B with a priority THREAD_PRIORITY_LOWEST is waiting for an event E (Note: at this point the thread is not scheduled because it is runnable, but A is higher priority and runnable as well) thread A calls SetThreadPriority(B, THREAD_PRIORITY_ABOVE_NORMAL) Is thread B re-scheduled immediately to run, or is thread A allowed to continue until current time-slice is over, and B is scheduled only once a new time-slice has begun? I would be interested to know the answer for WinXP, Vista and Win7, if possible. Note: the scenario above is simplified from my real world code, where multiple threads are running on multiple cores, but the main object of the question stays: does SetThreadPriority cause thread scheduling to happen?

    Read the article

  • SetWindowLongPtr with DialogBoxParam?

    - by templatetypedef
    Hey all- A while back I was writing a C++ program with the Win32 API that would display a dialog box and then listen to the messages it generated. At one point, I was interested in associating a piece of data with the dialog window. Were I manually creating the window and attaching a window proc, I'd just use SetWindowLongPtr to set the GWLP_USERDATA field to a pointer to the data to associate. However, in this case I was creating and displaying the window with DialogBoxParam, and it wasn't clear whether this function was associating that data with its own internal state. Since the MSDN didn't have a description of what would happen in this case, I ended up using some other approach to solve the problem. My question is this - is it safe to use SetWindowLongPtr to overwrite the GWLP_USERDATA value in a window created by DialogBoxParam? Thanks!

    Read the article

  • Rewrite Registry File in Windows

    - by Vulcan Eager
    I have been trying to find a way to "defragment" the registry on my Windows machine. Firstly, does this make sense? Any benefits in doing this? (Not much love on superuser.com) Secondly, I am looking for a way to rewrite the registry using C/C++ with Windows API. Is there a way to read the registry and write it to a new file getting rid of unused bytes along the way? (I might have to write the new file and then boot into another OS/disk before I can overwrite the original... but I am willing to take that risk.)

    Read the article

  • Removing and restoring Window borders

    - by Laurence
    I want to remove the window borders of another process in C#; I used RemoveMenu to remove the borders. It almost works but I have 2 problems left: I need to remove the borders twice, the first time the menu bar still exists. I can’t restore the menu’s This is what I already wrote: public void RemoveBorders(IntPtr WindowHandle, bool Remove) { IntPtr MenuHandle = GetMenu(WindowHandle); if (Remove) { int count = GetMenuItemCount(MenuHandle); for (int i = 0; i < count; i++) RemoveMenu(MenuHandle, 0, (0x40 | 0x10)); } else { SetMenu(WindowHandle,MenuHandle); } int WindowStyle = GetWindowLong(WindowHandle, -16); //Redraw DrawMenuBar(WindowHandle); SetWindowLong(WindowHandle, -16, (WindowStyle & ~0x00080000)); SetWindowLong(WindowHandle, -16, (WindowStyle & ~0x00800000 | 0x00400000)); } Can someone show me what I did wrong? I already tried to save the MenuHandle and restore it later, but that doesn't work.

    Read the article

  • AllowSetForegroundWindow & SetForegroundWindow: NPAPI plug-in wants to allow a desktop application with no success

    - by David Robert Jones
    Here it's what I have: a web browser plug-in written in C++ and a Windows application written in C#. They communicate through a named pipe. The plug-in instructs the C# application to open a file (suppose that the file is a .txt and it opens in Notepad). Once the C# application is given the command, it opens the file but Notepad doesn't show in the foreground, which isn't acceptable, I must open Notepad in the foreground. I modified the C# application so that it calls the SetForegroundWindow function. This time Notepad didn't open in the foreground, but the taskbar flashes. After reading the documentation for SetForegroundWindow and many articles I think that now I understand what the problem is: the C# application can't bring Notepad to the foreground because it wasn't the the foreground process, the browser was (?). After reading this: "A process that can set the foreground window can enable another process to set the foreground window by calling the AllowSetForegroundWindow function." I decided to modify the plug-in. This time the plug-in calls the AllowSetForegroundWindow function passing ASFW_ANY as a parameter (I know, ASFW_ANY could be risky, but I wanted to make sure that AllowSetForegroundWindow would do it). After I did the modification to the plug-in I tested it and it worked! (Opera 12.02). Then I tested it on Internet Explorer and it worked too. But the problem came when I tested it in Firefox and Chrome. The C# application didn't have the ability to bring Notepad to the foreground. I noticed that for those browsers the AllowSetForegroundWindow function was returning false. So I started investigating and I come to the conclusion that maybe it's because the plugin container that Firefox uses. An idea came to my mind: it worked in Opera 12.02, but they don't have a plugin container, although they did in Opera 12.00. So I downloaded Opera 12.00, I did the test and it failed, which makes me conclude that the plugin container is the culprit. The question is: how can I give to the C# application the ability to set foreground? I don't know how to continue, and I think that I tried all the legitimate ways. The AllowSetForegroundWindow & SetForegroundWindow seems to not apply here.

    Read the article

  • Access violation C++ (Deleting items in a vector)

    - by Gio Borje
    I'm trying to remove non-matching results from a memory scanner I'm writing in C++ as practice. When the memory is initially scanned, all results are stored into the _results vector. Later, the _results are scanned again and should erase items that no longer match. The error: Unhandled exception at 0x004016f4 in .exe: 0xC0000005: Access violation reading location 0x0090c000. // Receives data DWORD buffer; for (vector<memblock>::iterator it = MemoryScanner::_results.begin(); it != MemoryScanner::_results.end(); ++it) { // Reads data from an area of memory into buffer ReadProcessMemory(MemoryScanner::_hProc, (LPVOID)(*it).address, &buffer, sizeof(buffer), NULL); if (value != buffer) { MemoryScanner::_results.erase(it); // where the program breaks } }

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30  | Next Page >