Skip to content

Windows API

Discussions on the APIs of the various versions of Windows

This category can be followed from the open social web via the handle windows-api@forum.codeproject.com

811 Topics 2.7k Posts
  • USB driver development for storage devices

    question workspace
    2
    0 Votes
    2 Posts
    2 Views
    J
    KMDF is a driver. It's the MS-provided framework, so you are in effect writing a windows driver. Never having done a storage driver, I can't help with writing a storage driver with KMDF (yes, no, hard, easy ...). I don't have the framework on this machine, but I seem to recall that it contained some storage driver samples, along with some USB samples. KMDF does work on XP, so I can't see a problem with which version of Windows you're targetting. Judy Be wary of strong drink. It can make you shoot at tax collectors - and miss. Lazarus Long, "Time Enough For Love" by Robert A. Heinlein
  • Win 7 Summary Shell Extension

    linux question
    8
    0 Votes
    8 Posts
    6 Views
    G
    If you don't mean a PreviewHandler (which I don't think you do), it's pretty easy. Returns a List of ListViewItem contains all the info. Do with it what you will. Mostly stolen from a sample in the WindowsAPICodePack1.1 available....somewhere. CodePlex? So it needs the DLLS, too. using System; using System.IO; using System.Collections; using Microsoft.WindowsAPICodePack.Shell; using System.Collections.Generic; using System.Windows.Forms; using Microsoft.WindowsAPICodePack.Shell.PropertySystem; using System.Linq; namespace DetailedFileInfo { class FileDetails { public List GetFileInfo(string Filename) { List aReturn = new List(); if (Filename.Length > 0) { string filter = null; string fileName = Path.GetFullPath(Filename); ShellPropertyCollection collection = new ShellPropertyCollection(fileName); var properties = collection .Where( prop => prop.CanonicalName != null && (filter == null ? true : prop.CanonicalName.StartsWith(filter, StringComparison.CurrentCultureIgnoreCase))) .ToArray(); Array.ForEach( properties, p => { aReturn.Add(DisplayPropertyValue(p)); }); } return aReturn; } private static ListViewItem DisplayPropertyValue(IShellProperty prop) { string value = string.Empty; value = prop.ValueAsObject == null ? "" : prop.FormatForDisplay(PropertyDescriptionFormatOptions.None); ListViewItem LVI = new ListViewItem(); if (prop.Description.DisplayName == null) { LVI.Text = prop.CanonicalName.Remove(0, prop.CanonicalName.LastIndexOf('.') + 1); LVI.SubItems.Add(value); return LVI; } else { LVI.Text = prop.Description.DisplayName; LVI.SubItems.Add(value); return LVI; } } } }
  • "Simple" capture pixel under mouse routine...

    tutorial question learning
    2
    0 Votes
    2 Posts
    4 Views
    P
    Note that the cursor shape is always changed on every mouse move because the windows that is under the cursor is always receiving WM_SETCURSOR message, so you are fighting against the windows that are under your cursor. On way to avoid that is capturing the mouse by your HWND. A good thing about mouse capturing is that while you capture the mouse, no WM_SETCURSOR messages are sent to windows under the cursor, so you can set your on cursor and it will stay until you release the capture. Here you can find a small example prog about using mouse capture. http://www.codeproject.com/Tips/127813/Using-SetCapture-and-ReleaseCapture-correctly.aspx[^]. Some hints about picking a color: The easiest way is to ask the user to move the cursor above a pixel and to ask him to press for example a key because you can not prevent the window below the cursor from receiving the click. Another more sophisticated solution can be creating a big window that covers the whole virtual screen (not THE SCREEN but the virtual screen including all monitors!) and you could capture and draw the actual image of the whole virtual screen on this big window. In this case you don't even need the SetCapture() trick, and its easy to receive the mouse click. Another quick note: If you use a window that covers the whole screen than either return 1 from the window's WM_ERASEBKGND message handler, or do the whole painting in WM_ERASEBKGND instead of WM_PAINT to avoid flickering when you show up the window! EDIT: Or maybe you could use a color picking mechanism that is similar to the HWND picker of spy++. The user presses down the left button on your color picker control that captures the mouse and sets the cursor. After it the user moves the cursor above a pixel and releases the left mouse button, this is when you take action. During mousemove you can update your info area to show something about the actual pixel. modified on Thursday, December 2, 2010 11:16 AM
  • 0 Votes
    2 Posts
    2 Views
    L
    My guess is the ALT+ENTER combination may do what you want it to do, but also still gets handled as a regular keyboard input and the system (or your app itself) is unhappy since the active control does not accept it as a valid input. If so, you need to tell your code the handling of the message is done, maybe trough the return value. BTW: please use PRE tags for showing code snippets. :) Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
  • Accessing HID Devices...

    json question
    2
    0 Votes
    2 Posts
    3 Views
    B
    Be very careful when using HID directly, strange things may happen. I remember a colleague of mine who experimented with a Philips DPM 9620 dictation device. Suddenly, it did not work correctly anymore, and insisted in being a Philips DPM 9370 (a far cheaper model). We were not able to treat that personality disorder...
  • 0 Votes
    3 Posts
    2 Views
    M
    I don't know what you want and what you have~sorry!
  • 0 Votes
    2 Posts
    2 Views
    V
    No one has knowledge so far?
  • CBT HOOK not called sometimes

    help hosting performance question
    2
    0 Votes
    2 Posts
    3 Views
    L
    dani kenan wrote: Are you familiar with this issue? No dani kenan wrote: Can you think of something we are doing wrong? Yes. maybe your comparison code isn't correct. Are you using a case-sensitive string compare? suggestion: log every DLL_PROCESS_ATTACH with its relevant data to a text file and inspect that. :) Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
  • Midi Message Buffer ?

    question graphics game-dev algorithms data-structures
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • 0 Votes
    1 Posts
    1 Views
    No one has replied
  • Custom Draw confusion

    visual-studio com graphics data-structures tutorial
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Getting DBLCLK Messages

    question
    3
    0 Votes
    3 Posts
    3 Views
    C
    Ah... excellent, thank you. I will try that, even though I did end up emulating double click. I thought there was likely an issue with trying to set a CS_XXX when all the others seemed to be WS_XXX or WS_EX_XXX, but somehow never tracked down the SetClassLongPtr functions. Thanks, CraigL
  • 0 Votes
    5 Posts
    5 Views
    S
    IIRC = If I Recall/Remember Correctly ?? I thought it could be some standard/specification related term :) Thanks, Sharath
  • 0 Votes
    1 Posts
    2 Views
    No one has replied
  • PeekMessage for Parent Window

    beta-testing question code-review workspace
    3
    0 Votes
    3 Posts
    3 Views
    S
    GetMessage[^] and PeekMessage[^] use the message queue: they will only work for messages that were posted (see PostMessage[^]). The WM_SIZE[^] message is sent (see SendMessage[^]). Subclassing or hooking (See SetWindowsHookEx[^]) is the way to go. Steve
  • 0 Votes
    1 Posts
    1 Views
    No one has replied
  • 0 Votes
    2 Posts
    2 Views
    X
    try it again the font oject is tempeory. so it will not be usefull. you can add a member variable.
  • Developers' forum for TAPI on Microsoft..

    help question
    2
    0 Votes
    2 Posts
    2 Views
    L
    overloaded Name wrote: I might be looking in the wrong places You certainly are. overloaded Name wrote: can you suggest me? Google. Just say 'NO' to evaluated arguments for diadic functions! Ash
  • How to redirect TCP packets

    c++ json tutorial question
    3
    0 Votes
    3 Posts
    5 Views
    Q
    I'm not sure that's what I want, but it is close. When I tested this, WinTunnel only accepted connections directed to localhost. What I want my code to do is act like a proxy between a mail client and mail server, just like the way the AVG email scanner works. And for it to tunnel a connection to any host from localhost on specific ports. So, if you open a command prompt and enter: telnet somemailserver.com 110 the AVG mail scanner picks up that connection and redirects it to localhost:10110. It then forwards the request to somemailserver.com:110 and can scan mails for viruses as it is in between the mail client and the mail server. So the main thing being that when a mail client believes it is accessing a mail server for an account, it actually isn't. It is accessing the AVG email scanner proxy. I thought that AVG may be using Winsock LSP, but I see no providers other than the standard ones when I list them out. Not sure if raw sockets can do what I want either. modified on Thursday, September 23, 2010 3:41 AM
  • How to learn Visual Studio

    tutorial csharp c++ database visual-studio
    10
    0 Votes
    10 Posts
    9 Views
    M
    Joe Q wrote: I'd rather not use C#, I work with 2 guys who became C# experts and now choose to never use it again. They have a whole list of reasons why but when they get on their anti-C# soap boxes I usually excuse myself becasue I know they'll be at it for a while. Really? From my experience, and of the team on the last big project I was on (30+ programmers), C# is definitely a lot more productive easier to use than using C++, either managed or unmanged. And WinForms are a huge leap forward from MFC. Take a serious look at it, rather than listening to other people's opinions, and I think you might be pleasantly surprised... Days spent at sea are not deducted from one's alloted span - Phoenician proverb