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
  1. Home
  2. General Programming
  3. C#
  4. Imported DLL problem

Imported DLL problem

Scheduled Pinned Locked Moved C#
helpperformancequestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TimSWatson
    wrote on last edited by
    #1

    Hi Im having a problem getting the code below to work.

            compressorHnd = Avi.ICOpen(Avi.FOURCC.ICTYPE\_VIDEO, Avi.FOURCC.DIVX, Avi.ICMODE.ICMODE\_COMPRESS);         
            
            pCV = new Avi.COMPVARS();
            pCV.cbSize = Marshal.SizeOf(pCV);
            pCV.hic = compressorHnd;
            pCV.dwFlags = 1;
            pCV.fccHandler = Avi.FOURCC.DIVX;
            pCV.fccType = Avi.FOURCC.ICTYPE\_VIDEO;
    
            outbi = new Avi.BITMAPINFOHEADER();
            outbi.biSize = Marshal.SizeOf(outbi); // 40
            outbi.biWidth = 640;
            outbi.biHeight = 480;
            outbi.biPlanes = 1;
            outbi.biBitCount = 24;
            outbi.biCompression = 0;
            
            Avi.ICSeqCompressFrameStart(pCV, ref outbi);
    
            bool key = false; long size = 0; 
    
            IntPtr r = (IntPtr)Avi.ICSeqCompressFrame(pCV, 0, image.ToArray(), ref key, ref size);
    

    The code causes an "System.AccessViolationException: Attempted to read or write protected memory" exception on the last line. ICSeqCompressFrame is imported using the code,

       \[DllImport("MSVFW32.dll")\]
            public static extern int ICSeqCompressFrame(
                COMPVARS pc,
                int uiFlags,
                byte\[\] lpBits,
                ref bool pfKey,
                ref long plSize
                );
    

    Can anyone help me out?

    L D 2 Replies Last reply
    0
    • T TimSWatson

      Hi Im having a problem getting the code below to work.

              compressorHnd = Avi.ICOpen(Avi.FOURCC.ICTYPE\_VIDEO, Avi.FOURCC.DIVX, Avi.ICMODE.ICMODE\_COMPRESS);         
              
              pCV = new Avi.COMPVARS();
              pCV.cbSize = Marshal.SizeOf(pCV);
              pCV.hic = compressorHnd;
              pCV.dwFlags = 1;
              pCV.fccHandler = Avi.FOURCC.DIVX;
              pCV.fccType = Avi.FOURCC.ICTYPE\_VIDEO;
      
              outbi = new Avi.BITMAPINFOHEADER();
              outbi.biSize = Marshal.SizeOf(outbi); // 40
              outbi.biWidth = 640;
              outbi.biHeight = 480;
              outbi.biPlanes = 1;
              outbi.biBitCount = 24;
              outbi.biCompression = 0;
              
              Avi.ICSeqCompressFrameStart(pCV, ref outbi);
      
              bool key = false; long size = 0; 
      
              IntPtr r = (IntPtr)Avi.ICSeqCompressFrame(pCV, 0, image.ToArray(), ref key, ref size);
      

      The code causes an "System.AccessViolationException: Attempted to read or write protected memory" exception on the last line. ICSeqCompressFrame is imported using the code,

         \[DllImport("MSVFW32.dll")\]
              public static extern int ICSeqCompressFrame(
                  COMPVARS pc,
                  int uiFlags,
                  byte\[\] lpBits,
                  ref bool pfKey,
                  ref long plSize
                  );
      

      Can anyone help me out?

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, AFAIK you can't pass arrays like that, you need to offer some help. Here[^] is a little article explaining some ways that do work. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      Prolific encyclopedia fixture proof-reader browser patron addict?
      We all depend on the beast below.


      1 Reply Last reply
      0
      • T TimSWatson

        Hi Im having a problem getting the code below to work.

                compressorHnd = Avi.ICOpen(Avi.FOURCC.ICTYPE\_VIDEO, Avi.FOURCC.DIVX, Avi.ICMODE.ICMODE\_COMPRESS);         
                
                pCV = new Avi.COMPVARS();
                pCV.cbSize = Marshal.SizeOf(pCV);
                pCV.hic = compressorHnd;
                pCV.dwFlags = 1;
                pCV.fccHandler = Avi.FOURCC.DIVX;
                pCV.fccType = Avi.FOURCC.ICTYPE\_VIDEO;
        
                outbi = new Avi.BITMAPINFOHEADER();
                outbi.biSize = Marshal.SizeOf(outbi); // 40
                outbi.biWidth = 640;
                outbi.biHeight = 480;
                outbi.biPlanes = 1;
                outbi.biBitCount = 24;
                outbi.biCompression = 0;
                
                Avi.ICSeqCompressFrameStart(pCV, ref outbi);
        
                bool key = false; long size = 0; 
        
                IntPtr r = (IntPtr)Avi.ICSeqCompressFrame(pCV, 0, image.ToArray(), ref key, ref size);
        

        The code causes an "System.AccessViolationException: Attempted to read or write protected memory" exception on the last line. ICSeqCompressFrame is imported using the code,

           \[DllImport("MSVFW32.dll")\]
                public static extern int ICSeqCompressFrame(
                    COMPVARS pc,
                    int uiFlags,
                    byte\[\] lpBits,
                    ref bool pfKey,
                    ref long plSize
                    );
        

        Can anyone help me out?

        D Offline
        D Offline
        David Knechtges
        wrote on last edited by
        #3

        Looks to me like your pinvoke signature is wrong. Several of the items are declared as the items themselves, not as pointers like the actual function expects: pc lpBits pfKey plSize Use this tool to help you generate the pinvoke signatures: http://download.microsoft.com/download/f/2/7/f279e71e-efb0-4155-873d-5554a0608523/CLRInsideOut2008_01.exe[^] And when you get them generated, please post them on www.pinvoke.net for others to use. I used that same tool to help me generate pinvoke signatures for the wifi DLL in Windows.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

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