请教:代码实现自动启动ASP.NET2.0支持?

littletemp 2007-12-11 05:33:29
我通过计算机管理MMC窗口建立新站点会启用ASP.NET2.0支持及其它权限配置,
但现在我想用mfc代码实现IIS站点自动配置,其它权限都已成功,只是ASP.NET2.0服务支持无法启用,
我的问题是:如何用vc++代码实现自动启动asp.net2.0支持?
哪位高手帮帮忙,将非常感谢!能实现功能即刻结帖。
...全文
76 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
littletemp 2007-12-12
  • 打赏
  • 举报
回复
谢谢!我先试试!
青稞 2007-12-12
  • 打赏
  • 举报
回复
楼上的貌似不错,楼主不妨试试吧。。呵呵,帮顶,学习中。。
littletemp 2007-12-12
  • 打赏
  • 举报
回复
非常感谢!
littletemp 2007-12-12
  • 打赏
  • 举报
回复
我在Server版系统上测试时发现asp.net版本属性自动加上了默认版本(正是我需要的),而XP系统则是空白。也许是我的XP系统只允许建立一个站点的原因。将来主要是在服务器版系统上使用,对于单机版还需优化一下代码判断。

谢谢几上各位大虾!这就准备结帖。
feng1976 2007-12-12
  • 打赏
  • 举报
回复
StartService

给你个小例子
DWORD StartSampleService()
{
SERVICE_STATUS ssStatus;
DWORD dwOldCheckPoint;
DWORD dwStartTickCount;
DWORD dwWaitTime;
DWORD dwStatus;

schService = OpenService(
schSCManager, // SCM database
"Sample_Srv", // service name
SERVICE_ALL_ACCESS);

if (schService == NULL)
{
MyErrorExit("OpenService");
}

if (!StartService(
schService, // handle to service
0, // number of arguments
NULL) ) // no arguments
{
MyErrorExit("StartService");
}
else
{
printf("Service start pending.\n");
}

// Check the status until the service is no longer start pending.

if (!QueryServiceStatus(
schService, // handle to service
&ssStatus) ) // address of status information structure
{
MyErrorExit("QueryServiceStatus");
}

// Save the tick count and initial checkpoint.

dwStartTickCount = GetTickCount();
dwOldCheckPoint = ssStatus.dwCheckPoint;

while (ssStatus.dwCurrentState == SERVICE_START_PENDING)
{
// Do not wait longer than the wait hint. A good interval is
// one tenth the wait hint, but no less than 1 second and no
// more than 10 seconds.

dwWaitTime = ssStatus.dwWaitHint / 10;

if( dwWaitTime < 1000 )
dwWaitTime = 1000;
else if ( dwWaitTime > 10000 )
dwWaitTime = 10000;

Sleep( dwWaitTime );

// Check the status again.

if (!QueryServiceStatus(
schService, // handle to service
&ssStatus) ) // address of structure
break;

if ( ssStatus.dwCheckPoint > dwOldCheckPoint )
{
// The service is making progress.

dwStartTickCount = GetTickCount():
dwOldCheckPoint = ssStatus.dwCheckPoint;
}
else
{
if(GetTickCount()-dwStartTickCount > ssStatus.dwWaitHint)
{
// No progress made within the wait hint
break;
}
}
}

if (ssStatus.dwCurrentState == SERVICE_RUNNING)
{
printf("StartService SUCCESS.\n");
dwStatus = NO_ERROR;
}
else
{
printf("\nService not started. \n");
printf(" Current State: %d\n", ssStatus.dwCurrentState);
printf(" Exit Code: %d\n", ssStatus.dwWin32ExitCode);
printf(" Service Specific Exit Code: %d\n",
ssStatus.dwServiceSpecificExitCode);
printf(" Check Point: %d\n", ssStatus.dwCheckPoint);
printf(" Wait Hint: %d\n", ssStatus.dwWaitHint);
dwStatus = GetLastError();
}

CloseServiceHandle(schService);
return dwStatus;
}
littletemp 2007-12-11
  • 打赏
  • 举报
回复
快沉底了,自己顶一下!

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧