我已经解决这个问题了,如果你会VC++的话,这很简单,如果你想用VB实现的话,代码看起来也不难,不过理解起来你可能会摸不着头的,给你个代码看看:
我可是抱着微软VB开发小组的Matthew Curland写的Advanced visual baisc 6英文版苦读半年的结果(结果我从英盲已经发展到可以过六级的地步了),当然下面的代码是不能运行的,要想运行就也读半年的书再说吧,这对你们有好处。看看MSDN也会对你有帮助的。
Private Sub Form_Load() Dim oROT As IRunningObjectTable Dim oEnmMk As IEnumMoniker Dim oMK As IMoniker Dim oBC As IBindCtx Dim lPtr As Long Dim sName As String Dim obj As Object Dim oCadApp As AcadApplication Dim j As AcadDocument Set oROT = GetRunningObjectTable Set oBC = CreateBindCtx Set oEnmMk = oROT.EnumRunning Do While oEnmMk.Next(1, oMK) = 0 Set obj = oROT.GetObject(oMK) If TypeOf obj Is AcadDocument Then Set j = obj Debug.Print j.Name End If Loop Set oROT = Nothing End Sub
|