ModulVer.cpp
上传用户:shouhua
上传日期:2014-12-06
资源大小:5685k
文件大小:2k
- ////////////////////////////////////////////////////////////////
- // 1998 Microsoft Systems Journal
- // If this code works, it was written by Paul DiLascia.
- // If not, I don't know who wrote it.
- //#include "..stdafx.h"//Release模式路径
- #include "stdafx.h"//Debug模式路径
- #include "ModulVer.h"
- CModuleVersion::CModuleVersion()
- {
- m_pVersionInfo = NULL; // raw version info data
- }
- //////////////////
- // Destroy: delete version info
- //
- CModuleVersion::~CModuleVersion()
- {
- delete [] m_pVersionInfo;
- }
- void CModuleVersion::ParseString(IN LPCSTR pSource, OUT LPSTR pTarget)
- {
- ASSERT(pSource);
- CString strTemp, strTemp1;
- strTemp = pSource;
- int nPos = 0, nPos2 = 0;
- if(-1 != strTemp.Find('"'))
- {
- nPos = strTemp.Find('"', 1);
- strTemp.Delete(0, 1);
- strTemp1 = strTemp.Left(nPos - 1);
- if(-1 == strTemp1.ReverseFind('.'))
- {
- strTemp1 += ".exe";
- }
- strncpy(pTarget, strTemp1, strTemp1.GetLength());
- return;
- }
- strTemp.MakeLower();
- nPos2 = strTemp.Find("rundll32.exe");
- if(-1 != nPos2)
- {
- strTemp.Delete(0, nPos2+13);
- nPos2 = -1;
- nPos2 = strTemp.Find(',');
- if(-1 != nPos2)
- {
- strncpy(pTarget, strTemp, nPos2);
- return;
- }
- else
- {
- strncpy(pTarget, strTemp, strTemp.GetLength());
- return;
- }
- }
- strTemp.MakeLower();
- nPos = strTemp.Find("rundll32");
- if(-1 != nPos)
- {
- strTemp.Delete(0, nPos+9);
- nPos2 = -1;
- nPos2 = strTemp.Find(',');
- if(-1 != nPos2)
- {
- strncpy(pTarget, strTemp, nPos2);
- return;
- }
- else
- {
- strncpy(pTarget, strTemp, strTemp.GetLength());
- return;
- }
- }
- nPos = strTemp.ReverseFind('\');
- if(-1 != nPos)
- {
- nPos2 = strTemp.Find(' ', nPos);
- if(-1 != nPos2)
- {
- strTemp1 = strTemp.Left(nPos2);
- if(-1 == strTemp1.ReverseFind('.'))
- {
- strTemp1 += ".exe";
- }
- strncpy(pTarget, strTemp1,strTemp1.GetLength());
- return;
- }
- else
- {
- int nPos3;
- nPos3 = -1;
- nPos3 = strTemp.Find("/", 0);
- if(nPos3 != -1)
- {
- strncpy(pTarget, strTemp, nPos3);
- }
- else
- {
- strncpy(pTarget, strTemp, strTemp.GetLength());
- }
- return;
- }
- }
- nPos = strTemp.Find(" ");
- if(-1 != nPos)
- {
- strncpy(pTarget, pSource, nPos);
- }
- else
- {
- strncpy(pTarget, pSource, strlen(pSource));
- return;
- }
- }