当pb生成的exe文件被指定为某种格式文件的默认打开方式时,
如果双击打开该种格式的文件,
则在文件被打开时,文件名会自动传入PB程序中,在application对象的open事件中,对commandline进行处理就可,以下为参考代码:
在open事件中写
if left(commandline,1) = '"' then commandline = mid(commandline,2) if right(commandline,1) = '"' then commandline = left(commandline, len(commandline) - 1) if commandline = "" or not fileexists(commandline) then open(w_main) //没有传入参数或者参数有误导致从参数中截取的文件路径不存在 else openwithparm(w_main, commandline) //此时commandline存储的是外部文件的路径 + 文件名 end if