Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

实现param读取 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 174 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results

[Dd]ebug/
[Rr]elease/
x64/
build/
app.publish/
[Bb]in/
[Oo]bj/

# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
!packages/*/build/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml
*.pubxml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/

# Windows Azure Build Output
csx
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
#*.pfx
*.publishsettings
*.bak

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
App_Data/*.mdf
App_Data/*.ldf

# =========================
# Windows detritus
# =========================

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Mac crap
.DS_Store

# =========================
# specifics
# =========================

App_Data/
glob:*.user
*.patch
*.hg
build/
_build/
/buildazure
/buildtasks
/artifacts
*.sln.cache
log.xml
profiling/
*.orig
*.itrace.csdef
*.build.csdef
src/TestResults/*
2 changes: 2 additions & 0 deletions ActiveXObject/ActiveXObject.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RegisterForComInterop>true</RegisterForComInterop>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -28,6 +29,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RegisterForComInterop>true</RegisterForComInterop>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down
151 changes: 128 additions & 23 deletions ActiveXObject/ObjectX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@


/// http://blogs.msdn.com/b/asiatech/archive/2011/12/05/how-to-develop-and-deploy-activex-control-in-c.aspx
/// http://stackoverflow.com/questions/11175145/create-com-activexobject-in-c-use-from-jscript-with-simple-event
/// http://stackoverflow.com/questions/11175145/create-com-activexobject-in-c-use-from-jscript-with-simple-event
/// http://stackoverflow.com/questions/421857/using-activex-propertybags-from-c-sharp
///
/// Register with & "$env:windir\Microsoft.NET\Framework\v4.0.30319\regasm" /codebase <full path of dll file>
/// Unregister with & "$env:windir\Microsoft.NET\Framework\v4.0.30319\regasm" /u <full path of dll file>
Expand All @@ -33,27 +34,131 @@ public interface IActiveX
{
[DispId(10)]
string CustomProperty { get; set; }
}

[ProgId("MyObject")]
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("7A5D58C7-1C27-4DFF-8C8F-F5876FF94C64")]
[ComSourceInterfaces(typeof(IActiveXEvents))]
public class MyObject : IActiveX
{

public delegate void OnContextChangeHandler(string data);
public event OnContextChangeHandler OnUpdateString;

[ComVisible(true)]
public string CustomProperty { get; set; }


[ComVisible(true)]
public void SayHello(string who)
{
OnUpdateString(who);
}
}

[ComVisible(true), ComImport,
Guid("37D84F60-42CB-11CE-8135-00AA004BB851"),//Guid("5738E040-B67F-11d0-BD4D-00A0C911CE86"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPersistPropertyBag //: IPersist
{
#region IPersist
[PreserveSig]
/*new*/ int GetClassID([Out] out Guid pClassID);
#endregion

[PreserveSig]
int InitNew();

[PreserveSig]
int Load(
[In] IPropertyBag pPropBag,
[In, MarshalAs(UnmanagedType.Interface)] object pErrorLog
);

[PreserveSig]
int Save(
IPropertyBag pPropBag,
[In, MarshalAs(UnmanagedType.Bool)] bool fClearDirty,
[In, MarshalAs(UnmanagedType.Bool)] bool fSaveAllProperties
);
}

[ComVisible(true), ComImport,
Guid("55272A00-42CB-11CE-8135-00AA004BB851"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPropertyBag
{
[PreserveSig]
int Read(
[In, MarshalAs(UnmanagedType.LPWStr)] string pszPropName,
[In, Out, MarshalAs(UnmanagedType.Struct)] ref object pVar,
[In] IntPtr pErrorLog);

[PreserveSig]
int Write(
[In, MarshalAs(UnmanagedType.LPWStr)] string pszPropName,
[In, MarshalAs(UnmanagedType.Struct)] ref object pVar);
}



[ProgId("MyObject")]
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[Guid("7A5D58C7-1C27-4DFF-8C8F-F5876FF94C64")]
[ComSourceInterfaces(typeof(IActiveXEvents))]
public class MyObject : IActiveX, IPersistPropertyBag, IPropertyBag
{

public delegate void OnContextChangeHandler(string data);
public event OnContextChangeHandler OnUpdateString;

[ComVisible(true)]
public string CustomProperty { get; set; }


[ComVisible(true)]
public void SayHello(string who)
{
OnUpdateString(who + " :CustomProperty=" + this.CustomProperty);
MessageBox.Show(" public void SayHello(string who):" + who + " :CustomProperty=" + this.CustomProperty);
}



#region IPropertyBag Members

public int Read(string pszPropName, ref object pVar, IntPtr pErrorLog)
{
pVar = null;
switch (pszPropName)
{
case "CustomProperty": pVar = this.CustomProperty; break;

}

return 0;
}

public int Write(string pszPropName, ref object pVar)
{
switch (pszPropName)
{
case "CustomProperty": this.CustomProperty = (string)pVar; break;
}

return 0;
}

#endregion

#region IPersistPropertyBag Members

public int GetClassID(out Guid pClassID)
{
throw new NotImplementedException();
}

public int InitNew()
{
return 0;
}

public int Load(IPropertyBag pPropBag, object pErrorLog)
{
object val = null;

pPropBag.Read("CustomProperty", ref val, IntPtr.Zero);
Write("CustomProperty", ref val);
return 0;
}

public int Save(IPropertyBag pPropBag, bool fClearDirty, bool fSaveAllProperties)
{
return 0;
}

#endregion

}
}
Loading