Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

Paolo Vernazza

@Paolo Vernazza
About
Posts
29
Topics
11
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Dll Callback and shared memory [modified]
    P Paolo Vernazza

    Great, it worked!

    C# performance help question

  • Dll Callback and shared memory [modified]
    P Paolo Vernazza

    Mark Salsbery wrote:

    This typedef UCHAR (__cdecl *RESPONSE_FUNC)(UCHAR eventID); should be typedef UCHAR (__stdcall *RESPONSE_FUNC)(UCHAR eventID);

    It's a third party library, I'm not able to change it :( And yes, I'm sure the buffer is bigh enough... it should be 3 bytes, I'm passing 10 ;)

    C# performance help question

  • Dll Callback and shared memory [modified]
    P Paolo Vernazza

    I've a third party DLL that exports this function:

    typedef UCHAR (__cdecl *RESPONSE_FUNC)(UCHAR eventID);

    __declspec(dllimport) void SetCallback(RESPONSE_FUNC pfResponse, UCHAR* responseBuffer);

    I must allocate the buffer, call the SetCallback function, and read the modified data when the callback function is called. I tried with this code:

    static byte[] responseBuffer = new byte[10];

    delegate bool RESPONSE_FUNC(byte eventID);

    [DllImport("mydll.dll", CallingConvention=CallingConvention.Cdecl)]
    private static extern void ANT_SetCallback (RESPONSE_FUNC callback, byte[] responseBuffer);

    public void test
    {
    ANT_SetCallback (EventCallback, responseBuffer);
    }

    static bool EventCallback(byte eventID)
    {
    return true;
    }

    When the dll doesn't try to modify the buffer then the Callback function is called without errors(the first event doesn't access the buffer). But when the DLL tries to modify the data in the buffer, the program crashes with a 0xc0000409 exception. I'm stuck on this, any suggestion ?

    modified on Sunday, November 9, 2008 1:01 PM

    C# performance help question

  • Problem passing data to an activeX
    P Paolo Vernazza

    No, I haven't access to the activeX source code, but the activeX it is freely available at http://www.kolbasoft.com/ I put the test projects (c# and c++), the link to the activeX and a a few notes in www.vernazza.org/Vecad.zip I agree with you, it seems that GetData is passing out the long* that I passed it before instead of the data pointed, but I can't understand why it works while I call that function from c++ , and it doesn't when I call it from c#!

    C# c++ com debugging help question

  • Problem passing data to an activeX
    P Paolo Vernazza

    It doesn't work :( Your code works, but it stops if I use different unmanaged memory areas when storing and when retrieving or if I change the data in the unmanaged memory. For example, this code doesn't work: // Create buffer Int32[] buffer = new Int32[10]; buffer[5] = 1; // Allocate and copy to unmanaged memory IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Int32)) * 10); Marshal.Copy(buffer, 0, ptr, 10); // **** Need to add this, otherwise c# complains about not being able to convert IntPtr to int int bptr = (int)ptr; ocx.PutData(ref bptr, Marshal.SizeOf(typeof(Int32)) * 10); // Change buffer, so we can see that the ptr has restored the // old value buffer[5] = 2; // **** Allocate another are to retrieve data IntPtr ptr2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Int32)) * 10); int bptr2 = (int)ptr2; ocx.GetData(ref bptr2); // **** Here there is the problem: when GetData() returns, // the bptr2 variable has been changed and its value is = bptr = (int ptr) // Copy from unmanged memory back to array Marshal.Copy(ptr2, buffer, 0, 10); // Free memory, or else we will leak it Marshal.FreeHGlobal(ptr); Marshal.FreeHGlobal(ptr2);

    C# c++ com debugging help question

  • Problem passing data to an activeX
    P Paolo Vernazza

    I'm using in a project an activeX component with these 3 methods: public void PutData(ref int pData, int nBytes); public int GetDataSize(); public void GetData(ref int pData); The same functions, in a c++ project are: void PutData(long* pData, long nBytes); long GetDataSize(); void GetData(long* pData); With the first function I pass a buffer to the component and the component copies it in its own buffer. With the third function I pass a buffer to the component and the component copies in my buffer the data that it previously stored in its own buffer. I can't get the component work properly, because it seems to copy only the first 4 bytes (= the first integer). I tried the component in a c++ project and it works properly, so I think that the problem is in the way I'm passing the data to the activex. I use the functions in this way: int[] buffer = new int[10]; int[] buffer_check = new int[10]; for (int i=0; i<10; i++) buffer[i] = i; ocx.PutData(ref buffer[0], 10*sizeof(int)); //That's works OK System.Diagnostics.Debug.Assert(ocx.GetDataSize() == 10*sizeof(int)); ocx.GetData(ref buffer_check[0], 10*sizeof(int)); //This fails for any i != 0 for (i=0; i<10; i++) System.Diagnostics.Debug.Assert(buffer_check[i] == buffer[i]); Someone has any idea about what I'm doing wrong? Thanks! Paolo

    C# c++ com debugging help question

  • Wave files
    P Paolo Vernazza

    Hi, I'm looking for some wave files for simple events (success, fail). Do you know where I can find them?

    IT & Infrastructure question

  • SMS using C
    P Paolo Vernazza

    gsmlib is written in C. take a look

    Article Writing tutorial

  • Does anyone know of a good article about shrinking EXE sizes?
    P Paolo Vernazza

    If you want to keep it small then I think you should avoid using MFC.... write a simple application without them... Did you compiled your app using the static MFC library version? You cannot hope that who will use your installed has already the MFC Dlls

    C / C++ / MFC c++ question

  • ActiveX &amp; unicode
    P Paolo Vernazza

    [quote]Not being able to register sounds like it cannot be loaded.[/quote] It crashes and then reports the error "LoadLibrary failed". Yes, I'm using socket API with different unicode/ansi version. At first I had only the ansi version, but it gave me some problems with ext chars; also I don't know where to convert from unicode to ANSI, because the VC++ Wizard declares the called function using "LPCTSTR"...

    COM com question

  • ActiveX &amp; unicode
    P Paolo Vernazza

    I wrote an activex control that works well in W98. It had some problems with extended chars in WinwowsXP, so I recompiled it using unicode support. And now it works well in WinXP. But I can't register it win w98 nor in wme. Have I got to distribuite 2 versions (98/me and 2000/xp) or there is some way to have only one activeX working on both systems? Thanks Paolo

    COM com question

  • validity of HTREEITEM
    P Paolo Vernazza

    It represents some data stored in a DB; there are folders and subfolders. When the DB changes I need to update the corresponding tree item, so I must find it :) The three change frequently, also because the item may be deleted and cretated in another folder, so the cached data maybe obsolete. I think that GetItem is OK, thanks vladfein. Paolo

    C / C++ / MFC data-structures help question

  • validity of HTREEITEM
    P Paolo Vernazza

    I've a tree with many items and subitems; any item has an unique itemdata value. Sometimes I need to find the item that has a certain itemdata value. Actually I start by the ROOT item and I check every item and subitem looking for their itemdata values. The items I look for are usually few and I look for them very often, so I thought to use a CMAp for caching the last searches I did. The only problem is to know if the HTREEITEM I found in the map is still valid. Any idea?

    C / C++ / MFC data-structures help question

  • Shell open & working dir
    P Paolo Vernazza

    Thank you!!! It was so obvious, that I couldn't find it :)

    C / C++ / MFC windows-admin linux question

  • Shell open & working dir
    P Paolo Vernazza

    That could be a good solution, but I can't get the full command line... The variable m_lpCmdLine only contains "C:\CurrentFiles\myfile.paolo" without "F:\Apps\Mytool\Tool.exe" :(

    C / C++ / MFC windows-admin linux question

  • Shell open & working dir
    P Paolo Vernazza

    I don't need the file path, I want that the working path is the same of the exe. But I can't encode that in the source code, I must say that to she shell...

    C / C++ / MFC windows-admin linux question

  • Shell open & working dir
    P Paolo Vernazza

    I inserted in the registry (HKCR/myappdata/shell/open) the command line to open a file ("c:/programs dir/my app dir/myapp.exe" "%1") from the shell. Ok, it works, but the working dir is always "c:". I would like to tell Windows that when opening a file from the shell the working dir is "c:/programs dir/my app dir". A solution could be to write in the code SetCurrentDir(GetExeDirectory()), but doing so it would be impossible to use another working dir... Any suggestion? thanks

    C / C++ / MFC windows-admin linux question

  • Choose language
    P Paolo Vernazza

    I don't want to use satellite dll because: * I should insert bitmaps, toolbars and common resources in any dll wasting a lot of space * If I've all the resources in the same file, If I forgot a resource in a language (e.g. a string), the program use the resource in another languaga; using satellite DLL, it simply crashes!

    C / C++ / MFC c++ question announcement

  • Choose language
    P Paolo Vernazza

    I wrote a application using MFC & VC6. The resources I wrote are in two languages (english and italian). I would like to know if it is possible to change the reseource used language: i.e. I would like to be able to use the english version in an italian OS. I know that I can insert the resources in a satellite DLL, but that way has many contraindications. Any Idea?

    C / C++ / MFC c++ question announcement

  • CListCtrl Column width
    P Paolo Vernazza

    Using LVSCW_AUTOSIZE_USEHEADER has the same problem than using LVSCW_AUTOSIZE: if a non-visible string is longer than the header it isn't considered. Yes, what i'm doing il looking for the longest text extent (not the longest string, "w" is larger than "ll") and adding some pixel. But I would like to know how much should be "some pixel"... I think it depends on system font & some other param..

    C / C++ / MFC question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups