惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Last Week in AI
Last Week in AI
Project Zero
Project Zero
L
LINUX DO - 最新话题
C
Cisco Blogs
P
Privacy International News Feed
S
Schneier on Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Security @ Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
V
Vulnerabilities – Threatpost
W
WeLiveSecurity
Webroot Blog
Webroot Blog
K
Kaspersky official blog
Help Net Security
Help Net Security
博客园_首页
Security Archives - TechRepublic
Security Archives - TechRepublic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
雷峰网
雷峰网
The Last Watchdog
The Last Watchdog
WordPress大学
WordPress大学
IT之家
IT之家
Hugging Face - Blog
Hugging Face - Blog
A
Arctic Wolf
I
Intezer
V
V2EX
博客园 - 【当耐特】
Latest news
Latest news
T
Tenable Blog
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
Cyberwarzone
Cyberwarzone
量子位
G
GRAHAM CLULEY
T
Troy Hunt's Blog
博客园 - Franky
Simon Willison's Weblog
Simon Willison's Weblog
博客园 - 三生石上(FineUI控件)
TaoSecurity Blog
TaoSecurity Blog
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
Jina AI
Jina AI
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Scott Helme
Scott Helme

博客园 - 阿兰德隆

技术文章杂项罗列-1 ASP.NET CLIENTSIDE BEHAVIORS WSS Generic tech tutorials DATA concurrency in ADO.NET ASP.NET Browser compatibility related reference ***Internationalization related tech articles*** .net common utility frameworks WINFORM develop tech articles and tutorials VC++ third party shared components #Good EBook Download Sites ASP.NET Web Server Control 开发系列 工具系列 XML 相关技术 ASP.NET Performance Related Tech Reference Office document manipulation tech articles ASP.NET 第三方控件系列 层次型嵌套数据绑定以及关联数据插入模式 .NET 开发者10件必备武器:) ASP.NET BUILDIN FILEUPLOAD ISSUE
VS.NET DESIGN-TIME Issues
阿兰德隆 · 2004-08-02 · via 博客园 - 阿兰德隆

#VS.NET Design-time 获取当前的Project得目录路径
http://www.cnblogs.com/jonnyyu/archive/2004/02/20/1439.aspx?Pending=true#Post

#VB.NET 类似代码片断:

[VB.Net]
Imports System.ComponentModel
Imports System.Runtime.InteropServices

Module DTEUtils

    
Public ReadOnly VS2002MonikerBase As String = "!VisualStudio.DTE.7:"
    Public ReadOnly VS2003MonikerBase As String =
"!VisualStudio.DTE.7.1:"

    Public Enum VisualStudioVersion
        [VS2002]
        [VS2003]
    
End Enum


    
Private Class Win32API
        
<DllImport("ole32.dll")> _
        
Public Shared Function GetRunningObjectTable(ByVal reserved As
Integer<Out()> ByRef prot As UCOMIRunningObjectTable) As Integer
        
End Function


        
<DllImport("ole32.dll")> _
        
Public Shared Function CreateBindCtx(ByVal reserved As Integer,
<Out()> ByRef ppbc As UCOMIBindCtx) As Integer
        
End Function

    
End Class


    
Public Overloads Function GetVisualStudioMoniker(ByVal version As
VisualStudioVersion) 
As String
        
Dim strBase As String

        
Select Case version
            
Case VisualStudioVersion.VS2002
                strBase 
= VS2002MonikerBase
            
Case VisualStudioVersion.VS2003
                strBase 
= VS2003MonikerBase
        
End Select

        
Return strBase &
System.Diagnostics.Process.GetCurrentProcess().Id.ToString()
    
End Function


    
Public Overloads Function GetVisualStudioMoniker() As String
        
Return GetVisualStudioMoniker(VisualStudioVersion.VS2002)
    
End Function


    
Public Function GetDTE() As Object
        
Dim strMoniker As String =
GetVisualStudioMoniker(VisualStudioVersion.VS2002)
        
Dim objDTE As Object = GetMSDEVFromGIT(strMoniker)

        
If objDTE Is Nothing Then
            strMoniker 
=
GetVisualStudioMoniker(VisualStudioVersion.VS2003)
            objDTE 
= GetMSDEVFromGIT(strMoniker)
        
End If

        
Return objDTE
    
End Function


    
Public Overloads Function GetProjectUrl() As String
        
Return GetProjectUrl(GetDTE())
    
End Function


    
Public Overloads Function GetProjectUrl(ByVal DTE As ObjectAs
String
        
Dim strUrl As String

        
Try
            
Dim projs() As Object = DTE.ActiveSolutionProjects
            
Dim proj As Object = projs(0)
            strUrl 
= proj.Properties.Item("URL").Value
        
Catch exc As Exception
            Console.
WriteLine(exc.Message,
exc.GetBaseException.
GetType.Name)
            Console.
WriteLine(exc.StackTrace)
        
End Try

        
If Right(strUrl, 1= "/" Then strUrl = Left(strUrl, Len(strUrl)
- 1)

        
Return strUrl
    
End Function



    
Public Overloads Function GetProjectLocalPath() As String
        
Return GetProjectLocalPath(GetDTE())
    
End Function


    
Public Overloads Function GetProjectLocalPath(ByVal DTE As Object)
As String
        
Dim strPath As String

        
Try
            
Dim projs() As Object = DTE.ActiveSolutionProjects
            
Dim proj As Object = projs(0)
            strPath 
= proj.Properties.Item("LocalPath").Value
        
Catch exc As Exception
            Console.
WriteLine(exc.Message,
exc.GetBaseException.
GetType.Name)
            Console.
WriteLine(exc.StackTrace)
        
End Try

        
If Right(strPath, 1= "/" Then strPath = Left(strPath,
Len(strPath) - 1)

        
Return strPath
    
End Function



    
Public Function GetMSDEVFromGIT(ByVal strProgID As StringAs Object

        
Dim prot As UCOMIRunningObjectTable
        
Dim pMonkEnum As UCOMIEnumMoniker

        Win32API.GetRunningObjectTable(
0, prot)
        prot.EnumRunning(pMonkEnum)
        pMonkEnum.
Reset()

        
Dim fetched As Integer

        
Dim pmon(1As UCOMIMoniker


        
While pMonkEnum.Next(1, pmon, fetched) = 0
            
Dim pCtx As UCOMIBindCtx
            Win32API.CreateBindCtx(
0, pCtx)

            
Dim str As String
            pmon(
0).GetDisplayName(pCtx, Nothingstr)

            
If str = strProgID Then
                
Dim objReturnObject As Object
                prot.
GetObject(pmon(0), objReturnObject)
                
Return objReturnObject

            
End If

        
End While

        
Return Nothing

    
End Function



Public Function GetCurrentWebFormUrl()

       
Dim svc As IWebFormsDocumentService =
       Me.GetService(
GetType(IWebFormsDocumentService))
       
Return svc.DocumentUrl

End Function


End Module