Lm th? no ? p d?ng Windows XP ch? ? cho vn ph?ng COM add-in

D?ch tiu ? D?ch tiu ?
ID c?a bi: 830033 - Xem s?n ph?m m bi ny p d?ng vo.
Bung t?t c? | Thu g?n t?t c?

? Trang ny

TM T?T

Khi b?n t?o m?t COM add-in cho m?t chng tr?nh Microsoft Office (v d?, Microsoft Visio), s? xu?t hi?n c?a r?ng ti?n ch trong s? ph h?p b?i Theo m?c ?nh h?nh th?c vn ph?ng tiu chu?n. Tuy nhin, v?i Microsoft Windows XP, b?n c th? ch?n t? m?t s? ki?u tr?c quan (ho?c ch? ?) ? tu? ch?nh cc xu?t hi?n c?a m?t chng tr?nh Microsoft Windows.

Tr? khi c?a s? ch? ? m?t cch r? rng c hi?u l?c cho m?t COM add-in, s? xu?t hi?n c?a add-in th? khng thay ?i v?i cc l?c ? mu, d?n add-in xu?t hi?n ngy ho?c out-of-synch v?i chng tr?nh, ni n ?c ch?a. V?i Microsoft Visual C++ ho?c Microsoft Visual Studio.Ngn ng? NET, b?n c th? b?t COM c?a b?n Add-in ? l?a ch?n trong c?a s? ch? ?.

Khi b?n b?t m?t add-in cho C?a s? ch? ?, cc ch? ? ?nh h?ng ?n ch? l s? xu?t hi?n c?a add-in. Cc ch?c nng add-in khng b? ?nh h?ng.

Tuyn b? t? ch?i

Microsoft cung c?p l?p tr?nh v d? ? minh ho? ch?, khng c b?o hnh ho?c th? hi?n hay ng? ?. i?u ny bao g?m, nhng khng gi?i h?n, b?o ?m ng? ? kh? nng bn hng ho?c cho m?t m?c ch c? th?. Bi vi?t ny gi? ?nh r?ng b?n ? quen thu?c v?i ngn ng? l?p tr?nh m ang ?c ch?ng minh v v?i nh?ng cng c? ?c s? d?ng ? t?o ra v g? l?i th? t?c. Microsoft h? tr? cc k? s c th? gip gi?i thch cc ch?c nng c?a m?t th? t?c c? th?. Tuy nhin, h? s? s?a ?i cc v d? ? cung c?p thm ch?c nng ho?c xy d?ng quy tr?nh ? p ?ng cc yu c?u c? th? c?a b?n.

Microsoft Visual Basic 6.0

Visual Basic 6.0 h? tr? ch? ?. Add-in c th? khng ?c theo ch? ? b?ng cch s? d?ng Visual Basic 6.0.

Microsoft Visual C++ 6.0

S? d?ng Visual C++ 6.0 ? kch ho?t m?t COM thm vo ? l?a ch?n trong Windows XP ch? ?, h?y lm theo cc b?c sau:
  1. T?o m?t t?p tin b?n k c ch?a sau y thng tin. Ty ch?nh thng tin cho b?n c? th? thm trong:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
     <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
      <noInherit/>
      <assemblyIdentity 
       processorArchitecture="*" 
       type="win32" 
       name="MyOfficeNetAddin"
       version="1.0.0.0"/>
       <description>My Office Addin built with .Net</description> 
       <dependency optional="yes">                              
        <dependentAssembly>                   
         <assemblyIdentity                 
          type="win32"                
          name="Microsoft.Windows.Common-Controls" 
          version="6.0.1.0"           
          publicKeyToken="6595b64144ccf1df" 
          language="*"                
          processorArchitecture="*"/>
        </dependentAssembly>                  
       </dependency>                             
     </assembly>
    
  2. Thc hin mt trong nhng vic sau:
    • Bao g?m cc ch? d?n preprocessor sau y:
      #define ISOLATION_AWARE_ENABLED
      
    • Bin d?ch v?i:
      /D ISOLATION_AWARE_ENABLED
      
  3. Thm t?p k vo t?p tin ti nguyn c?a b?n, nh trong cc V d? sau:
    #include "windows.h"
    ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST "mydllname.dl.manifest"
    

Microsoft Visual Studio.NET v ngn ng? ?c qu?n l?

S? d?ng Visual Studio.NET v cc.NET Framework ? kch ho?t Windows XP ch? ? cho m?t COM thm vo, h?y lm theo cc b?c sau.

Chu y Trong v d? ny, C# ?c s? d?ng ? kch ho?t m?t b?i c?nh theo ch? ? kch ho?t trn m?t bi?u m?u Windows. Ngoi ra, ?i v?i Windows ch? ? c hi?u l?c cho nt, ki?m tra h?p, nt radio, v nhm h?p, cc FlatStyle ti s?n c?a cc ?i t?ng ph?i ?c thi?t l?p Cac vn .
  1. Bao g?m cc thng tin sau trong m?t t?p tin .cs. Ty ch?nh thng tin cho b?n c? th? thm trong:
    using System.Runtime.InteropServices;
    using System;
    using System.Security;
    using System.Security.Permissions;
    using System.Collections;
    using System.IO;
    using System.Text;
    using System.Windows.Forms;
    
    namespace MyOfficeNetAddin
    {
        /// <devdoc>
        ///     This class is intended to use with the C# 'using' statement in
        ///     to activate an activation context for turning on visual theming at
        ///     the beginning of a scope, and have it automatically deactivated
        ///     when the scope is exited.
        /// </devdoc>
    
    [ SuppressUnmanagedCodeSecurity ]
    internal class EnableThemingInScope : IDisposable
    {
       // Private data
    	  private uint  cookie;
       private static ACTCTX enableThemingActivationContext;
       private static IntPtr hActCtx;
       private static bool contextCreationSucceeded = false;
    
       public EnableThemingInScope(bool enable)
       {
       cookie = 0;
       if (enable && OSFeature.Feature.IsPresent(OSFeature.Themes))
       {
        if (EnsureActivateContextCreated())
        {
         if (!ActivateActCtx(hActCtx, out cookie))
         {
             // Be sure cookie always zero if activation failed
             cookie = 0;
         }
        }
       }
      }
    
      ~EnableThemingInScope()
      {
       Dispose(false);
      }
    
      void IDisposable.Dispose()
      {
       Dispose(true);
      }
    
      private void Dispose(bool disposing)
      {
       if (cookie != 0)
       {
        if (DeactivateActCtx(0, cookie))
        {
           // deactivation succeeded...
           cookie = 0;
        }
       }
      }
    
      private bool EnsureActivateContextCreated()
      {
       lock (typeof(EnableThemingInScope))
       {
        if (!contextCreationSucceeded)
        {
         // Pull manifest from the .NET Framework install
         // directory
    
         string assemblyLoc = null;
                            
         FileIOPermission fiop = new FileIOPermission(PermissionState.None);
         fiop.AllFiles = FileIOPermissionAccess.PathDiscovery;
         fiop.Assert();
         try
         {
          assemblyLoc = typeof(Object).Assembly.Location;
         }
         finally
         { 
          CodeAccessPermission.RevertAssert();
         }
    
         string manifestLoc = null;
         string installDir = null;
         if (assemblyLoc != null)
         {
          installDir = Path.GetDirectoryName(assemblyLoc);
          const string manifestName = "XPThemes.manifest";
          manifestLoc = Path.Combine(installDir, manifestName);
         }
    
         if (manifestLoc != null && installDir != null)
         {
          enableThemingActivationContext = new ACTCTX();
          enableThemingActivationContext.cbSize = Marshal.SizeOf(typeof(ACTCTX));
    	     enableThemingActivationContext.lpSource = manifestLoc;
    
          // Set the lpAssemblyDirectory to the install
          // directory to prevent Win32 Side by Side from
          // looking for comctl32 in the application
          // directory, which could cause a bogus dll to be
          // placed there and open a security hole.
    	     enableThemingActivationContext.lpAssemblyDirectory = installDir;
    	     enableThemingActivationContext.dwFlags = ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID; 
     
    	     // Note this will fail gracefully if file specified
          // by manifestLoc doesn't exist.
          hActCtx = CreateActCtx(ref enableThemingActivationContext);
          contextCreationSucceeded = (hActCtx != new IntPtr(-1));
         }
        }
    
        // If we return false, we'll try again on the next call into
        // EnsureActivateContextCreated(), which is fine.
        return contextCreationSucceeded;
       }
      }
    
      // All the pinvoke goo...
      [DllImport("Kernel32.dll")]
      private extern static IntPtr CreateActCtx(ref ACTCTX actctx);
      [DllImport("Kernel32.dll")]
      private extern static bool ActivateActCtx(IntPtr hActCtx, out uint lpCookie);
      [DllImport("Kernel32.dll")]
      private extern static bool DeactivateActCtx(uint dwFlags, uint lpCookie);
    
      private const int ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID = 0x004;
                
      private struct ACTCTX 
      {
       public int       cbSize;
       public uint      dwFlags;
       public string    lpSource;
       public ushort    wProcessorArchitecture;
       public ushort    wLangId;
       public string    lpAssemblyDirectory;
       public string    lpResourceName;
       public string    lpApplicationName;
      }
     }
    }
    
  2. T?o ra h?nh th?c c?a b?n v?i wrapper sau y. Th? t?c ny ?y m?t b?i c?nh theo ch? ? kch ho?t tr?c khi t?o ra b?t k? i?u khi?n:
    using( new EnableThemingInScope( true ) )
    {
     Form1 form1 = new Form1();
     form1.CreateControl();
    }
    

THAM KH?O

? bi?t thm v? cch s? d?ng Windows XP ki?u tr?c quan (ch? ?), truy c?p vo Microsoft MSDN Web site sau:
http://msdn2.Microsoft.com/en-US/Library/ms997646.aspx

Thu?c tnh

ID c?a bi: 830033 - L?n xem xt sau cng: 30 Thang Tam 2011 - Xem xt l?i: 2.0
p d?ng
  • Microsoft Office Basic 2007
  • Microsoft Office Basic Edition 2003
  • Microsoft Office Professional 2007
  • Microsoft Office Professional Edition 2003
  • Microsoft Office Small Business 2007
  • Microsoft Office Small Business Edition 2003
  • Microsoft Office Standard 2007
  • Microsoft Office Home and Student 2007
  • Microsoft Office Access 2007
  • Microsoft Office Access 2003
  • Microsoft Office Excel 2007
  • Microsoft Office Outlook 2007
  • Microsoft Office Outlook 2003
  • Microsoft Office PowerPoint 2007
  • Microsoft Office PowerPoint 2003
  • Microsoft Office Project Professional 2007
  • Microsoft Office Project Professional 2003
  • Microsoft Office Project Standard 2007
  • Microsoft Office Project Standard 2003
  • Microsoft Office Publisher 2007
  • Microsoft Office Publisher 2003
  • Microsoft Office Visio Professional 2007
  • Microsoft Office Visio Professional 2003
  • Microsoft Office Visio Standard 2007
  • Microsoft Office Word 2007
T? kha:
kbprogramming kbcode kbhowtomaster kbmt KB830033 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:830033

Cung cp Phan hi

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com