小隐的博客

人生在世,笑饮一生
posts - 178, comments - 295, trackbacks - 14, articles - 0
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

2012年1月11日

方法一:


select * from s600520 a
where not exists
(select 1 from s600520 b where a.CJDate =b.CJDate and b.CJTime >a.CJTime )
order by CJDate

 

方法二:
select * from (select *,row_number() over(partition by CJDate order by CJTime desc) rid from s600520)as l where rid =1

 

posted @ 2012-01-11 14:33 szyicol 阅读(11) 评论(0) 编辑

2012年1月7日

一直以来,觉得金山还是比较好用的,起码占用的系统资源还是比较满意的,不过今天偶然再一次证明云查杀都是忽悠人的!!

 

今天本来用VB6打算写个小工具,主要在跟随鼠标在屏幕上画一条线,写完后一运行,悲剧了,被金山报毒!

第一反应是VB6的编译器出了问题,以前遇到过delphi这样的问题,正在考虑要重装VB6时,突然想到,为何不写一个空代码的程序呢

于是什么都不干,新建了一个工程,编译成exe,用金山查杀,发现没有问题。

这样就排除了前面的想法。

于是回到代码 ,把某些API注释掉反复测试,发现了问题出在GetCursorPos 这个地方。。

 

也就是说金山毒霸是根据API来判断是否是病毒的。我的天,这样的杀毒软件也太好写了吧!!!

 

然后用云查杀,一样的结果,金山在心中的形象让我寒。。。

 

VB6所有代码贴出:

Private Const SWP_NOMOVE = 2
Private Const SWP_NOSIZE = 1
Private Const Flags = SWP_NOMOVE Or SWP_NOSIZE
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Dim p As POINTAPI


Public Function SetTopMostWindow(tHWND As Long, Topmost As Boolean) As Long
If Topmost = True Then ''Make the window topmost
SetTopMostWindow = SetWindowPos(tHWND, HWND_TOPMOST, 0, 0, 0, 0, Flags)
Else
SetTopMostWindow = SetWindowPos(tHWND, HWND_NOTOPMOST, 0, 0, 0, 0, Flags)
SetTopMostWindow = False
End If
End Function
Private Sub Form_Load()
Me.Height = 10
SetTopMostWindow Me.hwnd, True
Me.Width = Screen.Width / 2
'Me.Left = Screen.Width / 2
Timer1.Interval = 50
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
GetCursorPos p
Me.Top = p.y * Screen.TwipsPerPixelY + 15
Me.Left = p.x * Screen.TwipsPerPixelX - Me.Width / 3
End Sub



posted @ 2012-01-07 11:44 szyicol 阅读(103) 评论(1) 编辑

2011年12月16日

数据库已经56G了,有点大,虽然还没有对性能产生较大的影响,但每次自备份出来的实在是比较点空间。

于是今天把服务器上的数据进行了数据备份,然后把之前的数据进行了清除。

清除完成后进行了收缩,发现数据库大小一点都没变,狂晕!!

后来在网上找啊找,也没有找到原因!

再后来,在一个贴子上偶然一个字眼 "重启sql" 让我尝试了一下,于是我把数据库分离再附加再收缩

yes,,,目标完成,到了28G了

 

 

花了我7个小时!!!my god

posted @ 2011-12-16 10:43 szyicol 阅读(16) 评论(0) 编辑

2011年12月15日

using System;
using System.Diagnostics;

using System.Windows.Forms;
using System.Text.RegularExpressions;

using System.Collections.Generic;
using System.Text;
using System.IO;

/// <summary>
/// Helper class to decode HTML from the clipboard.
/// See http://blogs.msdn.com/jmstall/archive/2007/01/21/html-clipboard.aspx for details.
/// </summary>
class HtmlFragment
{
    #region Read and decode from clipboard
    /// <summary>
    /// Get a HTML fragment from the clipboard.
    /// </summary>    
    /// <example>
    ///    string html = "<b>Hello!</b>";
    ///    HtmlFragment.CopyToClipboard(html);
    ///    HtmlFragment html2 = HtmlFragment.FromClipboard();
    ///    Debug.Assert(html2.Fragment == html);
    /// </example>
    static public HtmlFragment FromClipboard()
    {
        if (Clipboard.ContainsText(TextDataFormat.Html))
        {
            MemoryStream ms = (MemoryStream)Clipboard.GetData("Html Format");
            ms.Position = 0;
            byte[] vBytes = new byte[ms.Length];
            ms.Read(vBytes, 0, (int)ms.Length);
            string rawClipboardText = Encoding.UTF8.GetString(vBytes);
            //string rawClipboardText = Clipboard.GetText(TextDataFormat.Html );
            HtmlFragment h = new HtmlFragment(rawClipboardText);
            return h;
        }
        else
        {
            return null;
        }
    }

    /// <summary>
    /// Create an HTML fragment decoder around raw HTML text from the clipboard. 
    /// This text should have the header.
    /// </summary>
    /// <param name="rawClipboardText">raw html text, with header.</param>
    public HtmlFragment(string rawClipboardText)
    {
        // This decodes CF_HTML, which is an entirely text format using UTF-8.
        // Format of this header is described at:
        // http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/clipboard/htmlclipboard.asp

        // Note the counters are byte counts in the original string, which may be Ansi. So byte counts
        // may be the same as character counts (since sizeof(char) == 1).
        // But System.String is unicode, and so byte couns are no longer the same as character counts,
        // (since sizeof(wchar) == 2). 
        int startHMTL = 0;
        int endHTML = 0;

        int startFragment = 0;
        int endFragment = 0;

        Regex r;
        Match m;

        r = new Regex("([a-zA-Z]+):(.+?)[\r\n]",
            RegexOptions.IgnoreCase | RegexOptions.Compiled);

        for (m = r.Match(rawClipboardText); m.Success; m = m.NextMatch())
        {
            string key = m.Groups[1].Value.ToLower();
            string val = m.Groups[2].Value;

            switch (key)
            {
                // Version number of the clipboard. Starting version is 0.9. 
                case "version":
                    m_version = val;
                    break;

                // Byte count from the beginning of the clipboard to the start of the context, or -1 if no context
                case "starthtml":
                    if (startHMTL != 0) throw new FormatException("StartHtml is already declared");
                    startHMTL = int.Parse(val);
                    break;

                // Byte count from the beginning of the clipboard to the end of the context, or -1 if no context.
                case "endhtml":
                    if (startHMTL == 0) throw new FormatException("StartHTML must be declared before endHTML");
                    endHTML = int.Parse(val);

                    //m_fullText = rawClipboardText.Substring(startHMTL, 3);
                    m_fullText = rawClipboardText.Substring(startHMTL);
                    //Console.WriteLine(m_fullText.Length );
                    //m_fullText = rawClipboardText.Substring(startHMTL, endHTML - startHMTL);
                    break;

                //  Byte count from the beginning of the clipboard to the start of the fragment.
                case "startfragment":
                    if (startFragment != 0) throw new FormatException("StartFragment is already declared");
                    startFragment = int.Parse(val);
                    break;

                // Byte count from the beginning of the clipboard to the end of the fragment.
                case "endfragment":
                    if (startFragment == 0) throw new FormatException("StartFragment must be declared before EndFragment");
                    endFragment = int.Parse(val);
                    m_fragment = rawClipboardText.Substring(startFragment, endFragment - startFragment);
                    break;

                // Optional Source URL, used for resolving relative links.
                case "sourceurl":
                    m_source = new System.Uri(val);
                    break;
            }
        } // end for

        if (m_fullText == null && m_fragment == null)
        {
            throw new FormatException("No data specified");
        }
    }


    // Data. See properties for descriptions.
    string m_version;
    string m_fullText;
    string m_fragment;
    System.Uri m_source;

    /// <summary>
    /// Get the Version of the html. Usually something like "1.0".
    /// </summary>
    public string Version
    {
        get { return m_version; }
    }


    /// <summary>
    /// Get the full text (context) of the HTML fragment. This includes tags that the HTML is enclosed in.
    /// May be null if context is not specified.
    /// </summary>
    public string Context
    {
        get { return m_fullText; }
    }


    /// <summary>
    /// Get just the fragment of HTML text.
    /// </summary>
    public string Fragment
    {
        get { return m_fragment; }
    }


    /// <summary>
    /// Get the Source URL of the HTML. May be null if no SourceUrl is specified. This is useful for resolving relative urls.
    /// </summary>
    public System.Uri SourceUrl
    {
        get { return m_source; }
    }

    #endregion // Read and decode from clipboard

    #region Write to Clipboard
    // Helper to convert an integer into an 8 digit string.
    // String must be 8 characters, because it will be used to replace an 8 character string within a larger string.    
    static string To8DigitString(int x)
    {
        //return String.Format("{0,8}", x);
        return x.ToString().PadLeft(8, '0');
    }

    /// <summary>
    /// Clears clipboard and copy a HTML fragment to the clipboard. This generates the header.
    /// </summary>
    /// <param name="htmlFragment">A html fragment.</param>
    /// <example>
    ///    HtmlFragment.CopyToClipboard("<b>Hello!</b>");
    /// </example>
    


    /// <summary>
    /// Clears clipboard and copy a HTML fragment to the clipboard, providing additional meta-information.
    /// </summary>
    /// <param name="htmlFragment">a html fragment</param>
    /// <param name="title">optional title of the HTML document (can be null)</param>
    /// <param name="sourceUrl">optional Source URL of the HTML document, for resolving relative links (can be null)</param>
    public static void CopyToClipboard(string htmlFragment)
    {


        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        // Builds the CF_HTML header. See format specification here:
        // http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/clipboard/htmlclipboard.asp

        // The string contains index references to other spots in the string, so we need placeholders so we can compute the offsets. 
        // The <<<<<<<_ strings are just placeholders. We'll backpatch them actual values afterwards.
        // The string layout (<<<) also ensures that it can't appear in the body of the html because the <
        // character must be escaped.
        string header =
@"Version:0.9
StartHTML:<<<<<<<1
EndHTML:<<<<<<<2
StartFragment:<<<<<<<3
EndFragment:<<<<<<<4
";

        string pre =
@"<!doctype html><html><BODY><!--StartFragment-->";

        string post = @"<!--EndFragment--></BODY></HTML>";

        sb.Append(header);


        int startHTML = sb.Length;

        sb.Append(pre);
        int fragmentStart = sb.Length;

        
        sb.Append(htmlFragment);
        int fragmentEnd = sb.Length;

        sb.Append(post);
        int endHTML = sb.Length;

        // Backpatch offsets
        sb.Replace("<<<<<<<1", To8DigitString(startHTML));
        sb.Replace("<<<<<<<2", To8DigitString(endHTML));
        sb.Replace("<<<<<<<3", To8DigitString(fragmentStart));
        sb.Replace("<<<<<<<4", To8DigitString(fragmentEnd));


        // Finally copy to clipboard.
        string data = sb.ToString();
        Clipboard.Clear();
        byte[] b = Encoding.Default.GetBytes(data);
        MemoryStream ms = new MemoryStream();
        ms.Write(b, 0, b.Length);
        Clipboard.SetData("Html Format", b);
        //Clipboard.SetText(data, TextDataFormat.Html);
    }
    public static void CopyHtmlToClipBoard(string html)
    {
        Encoding enc = Encoding.UTF8;

        string begin = "Version:0.9\r\nStartHTML:{0:000000}\r\nEndHTML:{1:000000}\r\nStartFragment:{2:000000}\r\nEndFragment:{3:000000}\r\n";

        string html_begin = "<html>\r\n<body>\r\n"
           + "<!--StartFragment-->";

        string html_end = "<!--EndFragment-->\r\n</body>\r\n</html>\r\n";

        string begin_sample = String.Format(begin, 0, 0, 0, 0);

        int count_begin = enc.GetByteCount(begin_sample);
        int count_html_begin = enc.GetByteCount(html_begin);
        int count_html = enc.GetByteCount(html);
        int count_html_end = enc.GetByteCount(html_end);

        string html_total = String.Format(
           begin
           , count_begin
           , count_begin + count_html_begin + count_html + count_html_end
           , count_begin + count_html_begin
           , count_begin + count_html_begin + count_html
           ) + html_begin + html + html_end;

        DataObject obj = new DataObject();
        obj.SetData(DataFormats.Html, new System.IO.MemoryStream(
           enc.GetBytes(html_total)));
        Clipboard.SetDataObject(obj, true);
    }
    #endregion // Write to Clipboard
} // end of class


HtmlFragment h = HtmlFragment.FromClipboard();
Console.WriteLine(h.Context );

//string htmlFragment = Encoding.UTF8.GetString(Encoding.Default.GetBytes("呵呵,测试一下"));
//HtmlFragment.CopyHtmlToClipBoard("<DIV>好像可以了</br>oh,mygod<IMG src=\"file:///C:\\b.jpg\"></DIV>");

  原文见

http://blogs.msdn.com/b/jmstall/archive/2007/01/21/sample-code-html-clipboard.aspx

http://blog.tcx.be/2005/08/copying-html-fragment-to-clipboard.html

posted @ 2011-12-15 17:29 szyicol 阅读(19) 评论(0) 编辑

2011年10月15日

不得不佩服QQ的通信方式,一丁点的流量,就可以玩了,而且很多公司拦不住QQ.

今天研究了一下,发现其实也是很普通。

这项研究要得益于比较好点的防火墙。我使用了outpost firewall

QQ在登陆之前,是有个设置的,可以设置要不要用代理,还有登陆的类型是TCP还是UDP

一直单纯的以为,QQ会按这些设置来登陆服务器。哈哈

不管怎么设置,QQ在登陆过程中,会用TCP,UDP和代理三种方式全部去尝试连接服务器,结果是哪个方式快,就用哪个连接方式

而且每个方式中,有很多服务器可以变换,一直到全部连接失败才弹出连接错误的提示框。

用防火墙可以清楚的看到连接了哪些方式,哪些服务器,直接禁掉,就好了,哈哈

了解这些,又可以用QQ做点事情了!!哈哈哈

posted @ 2011-10-15 09:06 szyicol 阅读(50) 评论(0) 编辑

2011年9月27日

摘要: 今天很恶心,碰到一个客户发来的excel有恶意代码,恶心,恶心在thisworkbook 中的代码Public WithEvents xx As ApplicationPrivate Sub Workbook_open()Set xx = ApplicationOn Error Resume NextIf Sheets(1).Name <> "Macro1" ThenCall auto_openEnd IfApplication.DisplayAlerts = FalseSecurity (1)Call SetAllowableVbeCall Microsoft阅读全文

posted @ 2011-09-27 18:11 szyicol 阅读(80) 评论(0) 编辑

摘要: 本来可以很简单的删除Dim vbc As ObjectSet vbc = ThisWorkbook.VBProject.VBComponents("模块1")ThisWorkbook.VBProject.VBComponents.Remove vbc但由于asp.net 用户权限的问题,不能如愿于是想了个新办法在运行宏后最后加了一段代码Dim n As StringDim n1 As Stringn1 = LCase(Workbooks(1).FullName)n = Replace(n1, ".xls", "--") & &阅读全文

posted @ 2011-09-27 18:04 szyicol 阅读(42) 评论(0) 编辑

2011年9月18日

摘要: @echo offset/p a=(把文件拖到本窗口回车删除,取消请关闭批处理) del %a% /q /f&cls@echo 已经删除任意键退出吧!&pause>nul 2>nul阅读全文

posted @ 2011-09-18 10:52 szyicol 阅读(42) 评论(0) 编辑

2011年9月6日

摘要: 看了下,安全模式也无法启动,启动到一半时自动重启,使用上次正确配置也无法启动,反复如此。无奈进入winpe ,资源管理器打开巨慢!!在cmd下 打开C盘,发现出现错误“执行页内操作时的错误”,基本确认是硬盘文件问题了。在网上找了下资料,CHKDSK C: /F 基本可以解决。根据损坏文件的不同,可能后续状态不同,反正是可以进系统了。我的IE损坏了,打开时报 0x5ddfddac”指令引用的“0x00000020”内存,该内存不能为read升级和修复都没用。后来再进入到winpe 连续两次CHKDSK C: /F ,终于好了。。贴一个案例:今天在学校的机器上使用的心爱的移动硬盘(主要是里面的东西阅读全文

posted @ 2011-09-06 11:38 szyicol 阅读(93) 评论(0) 编辑

2011年9月5日

摘要: 网上并没有太多完整的代码,只是对单字进行解码,或连续编码的解码,但如果中间插有字符或数字,就挂了贴一小段代码,可以解决了,原理其实就是以4个字符中一组,进行解码privateStringDecodeUnicode(StringdataStr){Regexreg=newRegex(@"(?i)\\[uU]([0-9a-f]{4})");returnreg.Replace(dataStr,delegate(Matchm){return((char)Convert.ToInt32(m.Groups[1].Value,16)).ToString();});}顺便说下,博客园的发文的阅读全文

posted @ 2011-09-05 10:27 szyicol 阅读(77) 评论(0) 编辑

QQ交流