js没有那么高的权限的
有的话也是ms的漏洞,需要打补丁的你自己从安全角度考虑一下就知道是不可能的了
有的话也是ms的漏洞,需要打补丁的你自己从安全角度考虑一下就知道是不可能的了
解决方案 »
- 关于for in
- 近日在学习js,有些问题想请教下大家,请多多帮忙啊
- 导航的jquery问题
- 关于点击文本框 文字消失的js问题
- 关于梅花雪菜单和树关联的疑问.
- cloneNode后,mergeAttributes不起作用!
- 请问:javascript:top.openBranch("我的网站")中的top是神末意思
- 求Tab面板,马上接贴,顶者有分~!
- www.blueidea.com中的“在线调查”饼图是怎么做的?
- 在html中根据单双周隐藏table内文本
- 紧接前面的提问再问大家:若第一个页面的值是通过session传到第二个页面的,该怎样实现子父窗口传值的问题。再次谢谢
- onmousemove的问题
------------------------------------------------------------------------------
设计思想:
通过RasGetEntryProperties()获取Phonebook Entry信息,然后改变其中的某些项的值,再通过RasSetEntryProperties()更新Phonebook Entry。用到的头文件和库文件:
ras.h,raserror.h,Rasapi32.libAPI原型:
DWORD RasGetEntryProperties(
LPCTSTR lpszPhonebook,
LPCTSTR lpszEntry,
LPRASENTRY lpRasEntry,
LPDWORD lpdwEntryInfoSize,
LPBYTE lpbDeviceInfo,
LPDWORD lpdwDeviceInfoSize
);
DWORD RasSetEntryProperties(
LPCTSTR lpszPhonebook,
LPCTSTR lpszEntry,
LPRASENTRY lpRasEntry,
DWORD dwEntryInfoSize,
LPBYTE lpbDeviceInfo,
DWORD dwDeviceInfoSize
);
主要实现代码:
/*获取LOCAL MACHINE上所有拨号连接,显示在一个LISTBOX中*/
void CRasDemoDlg::GetRasEntries()
{
DWORD dwCb = sizeof(RASENTRYNAME);
DWORD dwErr = ERROR_SUCCESS;
DWORD dwRetries = 5;
DWORD dwEntries = 0;
RASENTRYNAME* lpRasEntryName = NULL;
int count = m_listbox.GetCount();
for(int i = 1;i <= count;i++)
{
m_listbox.DeleteString(0);
}
//
// Loop through in case the information from RAS changes between calls.
//
while (dwRetries--)
{
//
// If the memory is allocated, free it.
//
if (NULL != lpRasEntryName)
{
HeapFree(GetProcessHeap(), 0, lpRasEntryName);
lpRasEntryName = NULL;
}
//
// Allocate the size need for the RAS structure.
//
lpRasEntryName = (RASENTRYNAME*)HeapAlloc(GetProcessHeap(), 0, dwCb);
if (NULL == lpRasEntryName)
{
dwErr = ERROR_NOT_ENOUGH_MEMORY;
break;
}
//
// Set the structure size for version checking purposes.
//
lpRasEntryName->dwSize = sizeof(RASENTRYNAME);
//
// Call the RAS API, bail on the loop if we are successful or an unknown
// error occurs.
//
dwErr = RasEnumEntries(
NULL,
NULL,
lpRasEntryName,
&dwCb,
&dwEntries);
if (ERROR_BUFFER_TOO_SMALL != dwErr)
{
break;
}
}
//
// In the success case print the names of the entries.
//
if (ERROR_SUCCESS == dwErr)
{
DWORD i; for (i = 0; i < dwEntries; i++)
{
m_listbox.InsertString(i,lpRasEntryName[i].szEntryName);
}
}
else
{
CString errMsg;
errMsg.Format("RasEnumEntries failed: Error = %d\n",dwErr);
AfxMessageBox(errMsg);
}
//
// Free the memory if necessary.
//
if (NULL != lpRasEntryName)
{
HeapFree(GetProcessHeap(), 0, lpRasEntryName);
lpRasEntryName = NULL;
}
}
/*通过LISTBOX,获取PHONEBOOK ENTRY的名称*/
void CRasDemoDlg::OnBnClickedButton2() //Update the selected Entry's Properties
{
int index = m_listbox.GetCurSel();
if ( -1 != index )
{
int msgBoxResult = MessageBox("Are you sure?","Attention Please",MB_YESNO|MB_ICONQUESTION);
if( msgBoxResult == IDYES )
{
CString EntryName;
m_listbox.GetText(index,EntryName);
if( TRUE == UpdateRasEntry(EntryName) )
{
AfxMessageBox("Updated succeeded!");
}
else
AfxMessageBox("Updated failed!");
}
}
else
{
AfxMessageBox("Please select a phonebook entry first!");
}
}/*通过从LISTBOX获取的ENTRY NAME,更新指定的ENTRY(注意:由于只是测试代码,没有加入异常处理)*/
BOOL CRasDemoDlg::UpdateRasEntry(LPCTSTR lpszEntry)
{
/* RasSetEntryProperties */
RASENTRY RasEntry;
RasEntry.dwSize = sizeof(RASENTRY);//can not be ommitted! dwSize identifies the version of RASENTRY
DWORD dwEntryInfoSize = 0; RasGetEntryProperties(NULL,lpszEntry,NULL,&dwEntryInfoSize,NULL,NULL);//Get the EntryInfoSize
RasGetEntryProperties(NULL,lpszEntry,&RasEntry,&dwEntryInfoSize,NULL,NULL);//Get the RasEntry
UpdateData(1);
strcpy(RasEntry.szLocalPhoneNumber, m_phonenumber);
RasSetEntryProperties(NULL,lpszEntry,&RasEntry,dwEntryInfoSize,NULL,NULL);//Update the RasEntry
/* RasSetEntryDialParams */
RASDIALPARAMS rasdialparams;
rasdialparams.dwSize = sizeof(RASDIALPARAMS);
BOOL fPassword;
strcpy(rasdialparams.szEntryName,lpszEntry);//can not be ommitted! szEntryName identifieds the very entry
RasGetEntryDialParams(NULL,&rasdialparams,&fPassword);//Get username and password
UpdateData(1);
strcpy(rasdialparams.szUserName,m_username);
strcpy(rasdialparams.szPassword,m_password);
RasSetEntryDialParams(NULL,&rasdialparams,FALSE); return TRUE;
}