Search Results

Search found 161 results on 7 pages for 'pinvoke'.

Page 5/7 | < Previous Page | 1 2 3 4 5 6 7  | Next Page >

  • How to use the ListView_GetBkImage macro in C#

    - by MusiGenesis
    How can I use the ListView_GetBkImage macro: http://msdn.microsoft.com/en-us/library/bb761246(v=VS.85).aspx ... from a C#/WinForms application? I think this macro just wraps the SendMessage method, but I'm not sure. I couldn't find any C#-based samples on this. Basically I'm trying to get a LVBKIMAGE ( http://msdn.microsoft.com/en-us/library/bb774742(v=VS.85).aspx ) structure that references the Desktop's background bitmap.

    Read the article

  • EntryPointNotFoundException when using TaskDialog in C#.

    - by horsedrowner
    I'm using the following code to call a TaskDialog. [DllImport("ComCtl32", CharSet = CharSet.Unicode, PreserveSig = false)] internal static extern void TaskDialogIndirect( [In] ref TASKDIALOGCONFIG pTaskConfig, [Out] out int pnButton, [Out] out int pnRadioButton, [Out] out bool pfVerificationFlagChecked); However, I get the exception "Unable to find an entry point named 'TaskDialogIndirect' in DLL 'ComCtl32'." I took this code. I am using Windows 7 x64 (RC). What am I doing wrong?

    Read the article

  • How to capture the event if a new process (application!) is started?

    - by Marcus
    I would like to have some eventhandler which raise if a new application is started. I've heard that this is possible by using a hook but the only examples I can find are based on mouse/keyboard events. What is an example link of how I can create such a hook in C#? Oh and btw: Nope, I don't want to use WMI which could be a solution as well but it's not an option in my case.

    Read the article

  • C# & C++, runtime error when call C++ dll from C#

    - by 5YrsLaterDBA
    I have written a C++ wrapper DLL for C# to call. The DLL was tested and worked fine with my C++ test program. now integrated with C#, I got runtime error and crashed. Cannot use debugger to see more details. The C++ side has only one method: #ifdef DLLWRAPPERWIN32_EXPORTS #define DLLWRAPPERWIN32_API __declspec(dllexport) #else #define DLLWRAPPERWIN32_API __declspec(dllimport) #endif #include "NB_DPSM.h" extern "C" { DLLWRAPPERWIN32_API int WriteGenbenchDataWrapper(string fileNameToAnalyze, string parameterFileName, string baseNameToSaveData, string logFileName, string& message) ; } in the C# side, there is a definition, [DllImport("..\\..\\thirdParty\\cogs\\DLLWrapperWin32.dll")] public static extern int WriteGenbenchDataWrapper(string fileNameToAnalyze, string parameterFileName, string baseNameToSaveData, string logFileName, ref string message); and a call: string msg = ""; int returnVal = WriteGenbenchDataWrapper(rawDataFileName, parameterFileName, outputBaseName, logFileName, ref msg); I guess there must be something wrong with the last parameter of the function. string& in C++ should be ref string in C#?

    Read the article

  • How do I marshal a pointer to an array of pointers to structures?

    - by Daniel Stutzbach
    I have a C function with the following signature: int my_function(int n, struct player **players) players is a pointer to an array of pointers to struct player objects. n is the number of pointers in the array. The function does not modify the array nor the contents of the structures, and it does not retain any pointers after returning. I tried the following: [DllImport("mylibary.dll")] static extern int my_function(int n, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] player_in []players); However, that marshals the data as a pointer to an array of structures, not a pointer to an array of pointers to structures.

    Read the article

  • How can I draw a hollow rectangle using CreatePen?

    - by LarsTech
    Since using the DrawArc function in GDI+ isn't very accurate when drawing a small rounded rectangle, I am using RoundRect instead. Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) Dim hDC As IntPtr = e.Graphics.GetHdc Dim rc As New Rectangle(10, 10, 64, 24) Dim hPen As IntPtr = Win32.CreatePen(Win32.PenStyle.PS_SOLID, 0, _ ColorTranslator.ToWin32(Color.Green)) Dim hOldPen As IntPtr = Win32.SelectObject(hDC, hPen) Call Win32.RoundRect(hDC, rc.Left, rc.Top, rc.Right, rc.Bottom, 10, 10) Win32.SelectObject(hDC, hOldPen) Win32.DeleteObject(hPen) e.Graphics.ReleaseHdc(hDC) MyBase.OnPaint(e) End Sub This will draw a nice rounded rectangle, but it will also fill it with a white brush, erasing what I don't want to have erased. How can I draw this without erasing the inside of the rectangle?

    Read the article

  • How can i use a C# dll in a Win32 C++ project ?

    - by Agito
    I am working on a solution, most of its core engine is developed as Win32 C++ (and is Platform independent and is also used on OS X), some time ago we needed to call C++ dll's of core engine from C# and I was able to Load main solution's DLL in C# (by the help of some threads here on SO). but now we have certain things implemented in Managed C# dll and need to use it in Win32 C++ project? (and just function definitions and dll are provided)

    Read the article

  • What does KEYEVENTF_SILENT equate to

    - by Vaccano
    KEYEVENTF_SILENT is a constant used in calls like this one: keybd_event(VK_OFF, 0, KEYEVENTF_SILENT, 0); keybd_event(VK_OFF, 0, KEYEVENTF_SILENT | KEYEVENTF_KEYUP, 0); But since I am using .net I don't know what the actual value of KEYEVENTF_SILENT is. I can't call it with out knowing. Any ideas?

    Read the article

  • How can i Import a Managed C# dll into a Win32 C++ project ?

    - by Agito
    I am working on a solution, most of its core engine is developed as Win32 C++ (and is Platform independent and is also used on OS X), some time ago we needed to call C++ dll's of core engine from C# and I was able to Load main solution's DLL in C# (by the help of some threads here on SO). but now we have certain things implemented in Managed C# dll and need to use it in Win32 C++ project? (and just function definitions and dll are provided)

    Read the article

  • How to show printer properties/preferences dialog and save changes?

    - by Patrick Klug
    I can't figure out how to properly show the printer preference dialog of a given printer so that the user can change the printer settings. Most of the examples that I can find online manage to show the dialog but any changes the user might make are lost which makes it useless. Example: http://www.codeproject.com/KB/system/PrinterPropertiesWindow.aspx (I tried to change the code as suggested by BartJoy but that didn't fix it) Does anyone know how to do this properly?

    Read the article

  • Why does String.Equals(Object obj) check to see if this == null?

    - by m-y
    // Determines whether two strings match. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] public override bool Equals(Object obj) { //this is necessary to guard against reverse-pinvokes and //other callers who do not use the callvirt instruction if (this == null) throw new NullReferenceException(); String str = obj as String; if (str == null) return false; if (Object.ReferenceEquals(this, obj)) return true; return EqualsHelper(this, str); } The part I don't understand is the fact that it is checking for the current instance, this, against null. The comment is a bit confusing, so I was wondering what does that comment actually mean? Can anyone give an example of how this could break if that check was not there, and does this mean that I should also place that check in my classes?

    Read the article

  • vb.net Is there a simple way to add a sound to a button click

    - by user867621
    Is there a simple way of doing this I found this online and I am getting an error Declare Function apisndPlaySound Lib "winmm" Alias "sndPlaySoundA" _ (ByVal filename As String, ByVal snd_async As Long) As Long Function PlaySound(ByVal sWavFile As String) ' Purpose: Plays a sound. ' Argument: the full path and file name. If apisndPlaySound(sWavFile, 1) = 0 Then MsgBox("The Sound Did Not Play!") End If End Function A call to PInvoke function 'WindowsApplication3!WindowsApplication3.Module1::apisndPlaySound' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

    Read the article

  • XNA extending an existing Content type

    - by Maarten
    We are doing a game in XNA that reacts to music. We need to do some offline processing of the music data and therefore we need a custom type containing the Song and some additional data: // Project AudioGameLibrary namespace AudioGameLibrary { public class GameTrack { public Song Song; public string Extra; } } We've added a Content Pipeline extension: // Project GameTrackProcessor namespace GameTrackProcessor { [ContentSerializerRuntimeType("AudioGameLibrary.GameTrack, AudioGameLibrary")] public class GameTrackContent { public SongContent SongContent; public string Extra; } [ContentProcessor(DisplayName = "GameTrack Processor")] public class GameTrackProcessor : ContentProcessor<AudioContent, GameTrackContent> { public GameTrackProcessor(){} public override GameTrackContent Process(AudioContent input, ContentProcessorContext context) { return new GameTrackContent() { SongContent = new SongProcessor().Process(input, context), Extra = "Some extra data" // Here we can do our processing on 'input' }; } } } Both the Library and the Pipeline extension are added to the Game Solution and references are also added. When trying to use this extension to load "gametrack.mp3" we run into problems however: // Project AudioGame protected override void LoadContent() { AudioGameLibrary.GameTrack gameTrack = Content.Load<AudioGameLibrary.GameTrack>("gametrack"); MediaPlayer.Play(gameTrack.Song); } The error message: Error loading "gametrack". File contains Microsoft.Xna.Framework.Media.Song but trying to load as AudioGameLibrary.GameTrack. AudioGame contains references to both AudioGameLibrary and GameTrackProcessor. Are we maybe missing other references? EDIT Selecting the correct content processor helped, it loads the audio file correctly. However, when I try to process some data, e.g: public override GameTrackContent Process(AudioContent input, ContentProcessorContext context) { int count = input.Data.Count; // With this commented out it works fine return new GameTrackContent() { SongContent = new SongProcessor().Process(input, context) }; } It crashes with the following error: Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 'C:\Users\Maarten\Documents\Visual Studio 2010\Projects\AudioGame\DebugPipeline\bin\Debug\DebugPipeline.exe'. Additional Information: A call to PInvoke function 'Microsoft.Xna.Framework.Content.Pipeline!Microsoft.Xna.Framework.Content.Pipeline.UnsafeNativeMethods+AudioHelper::OpenAudioFile' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature. Information from logger right before crash: Using "BuildContent" task from assembly "Microsoft.Xna.Framework.Content.Pipel ine, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553". Task "BuildContent" Building gametrack.mp3 -> bin\x86\Debug\Content\gametrack.xnb Rebuilding because asset is new Importing gametrack.mp3 with Microsoft.Xna.Framework.Content.Pipeline.Mp3Imp orter Im experiencing exactly this: http://forums.create.msdn.com/forums/t/75996.aspx

    Read the article

  • PInvokeStackImbalance was detected when manually running Xna Content pipeline

    - by Miau
    So I m running this code static readonly string[] PipelineAssemblies = { "Microsoft.Xna.Framework.Content.Pipeline.FBXImporter" + XnaVersion, "Microsoft.Xna.Framework.Content.Pipeline.XImporter" + XnaVersion, "Microsoft.Xna.Framework.Content.Pipeline.TextureImporter" + XnaVersion, "Microsoft.Xna.Framework.Content.Pipeline.EffectImporter" + XnaVersion, "Microsoft.Xna.Framework.Content.Pipeline.XImporter" + XnaVersion, "Microsoft.Xna.Framework.Content.Pipeline.AudioImporters" + XnaVersion, "Microsoft.Xna.Framework.Content.Pipeline.VideoImporters" + XnaVersion, }; more code in between ..... // Register any custom importers or processors. foreach (string pipelineAssembly in PipelineAssemblies) { _buildProject.AddItem("Reference", pipelineAssembly); } more code in between ..... var execute = Task.Factory.StartNew(() => submission.ExecuteAsync(null, null), cancellationTokenSource.Token); var endBuild = execute.ContinueWith(ant => BuildManager.DefaultBuildManager.EndBuild()); endBuild.Wait(); Basically trying to build the content project with code ... this works well if you remove XImporter, AudioIMporters and VideoImporters but with those I get the following error: PInvokeStackImbalance was detected Message: A call to PInvoke function 'Microsoft.Xna.Framework.Content.Pipeline!Microsoft.Xna.Framework.Content.Pipeline.UnsafeNativeMethods+AudioHelper::GetFormatSize' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature. Things I've tried: turn unsafe code on adding a lot of logging (the dll is found in case you are wondering) different wav and Mp3 files (just in case) Will update...

    Read the article

  • Problem invoking C DLL in C#

    - by CristiC
    I'm currently trying to invoke a method made in C from C# C code looks like this: extern "C" int addSum(int a, int b) { return a*b; } extern "C" int getCount() { return 12; } and C# code looks like this: [DllImport("mydll.dll", SetLastError=true)] private static extern int addSum(IntPtr a, IntPtr b); [DllImport("mydll.dll", SetLastError = true)] private static extern int getCount(); public static int mySum(int a, int b) { return suma(a, b); } public static int getMyCount() { return getCount(); } The code returns the right values but i'm getting the following error: addSum' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature. Any sugestion regarding this issue ? Thanks

    Read the article

  • Use the Cassia .NET Library to Detect Users Connected to Windows Server

    Thanks to the Cassia .NET Library, you can programmatically detect the users connected to Windows Server without using PInvoke to call the Windows Terminal Services API....Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Use the Cassia .NET Library to Detect Users Connected to Windows Server

    Thanks to the Cassia .NET Library, you can programmatically detect the users connected to Windows Server without using PInvoke to call the Windows Terminal Services API....Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Get started with C++ AMP

    - by Daniel Moth
    With the imminent release of Visual Studio 2012, even if you do not classify yourself as a C++ developer, C++ AMP is something you should learn so you can understand how to speed up your loops by offloading to the GPU the computation performed in the loop (assuming you have large number of iterations/data). We have many C# customers who are using C++ AMP through pinvoke, and of course many more directly from C++. So regardless of your programming language, I hope you'll find helpful these short videos that help you get started with C++ AMP C++ AMP core API introduction... from scratch Tiling Introduction - C++ AMP Matrix Multiplication with C++ AMP GPU debugging in Visual Studio 2012 In particular the work we have done for parallel and GPU debugging in Visual Studio 2012 is market leading, so check it out! Comments about this post by Daniel Moth welcome at the original blog.

    Read the article

< Previous Page | 1 2 3 4 5 6 7  | Next Page >