/**
@fn int assign_string(void* value_ptr, const char* value_string)
@note 对于value_string来说必须使用双引号,例如: tape_lable "matrixAL28"
*/
int assign_string(void* value_ptr, const char* value_string)
{
	int i_ret = APP_SUCCESS;
	char tmp_value[MAX_STRING_SIZE] = {0};
	char* ch_ptr = tmp_value;

	strcpy_s(tmp_value, MAX_STRING_SIZE - 1, value_string);
	while(*ch_ptr)
		if(*ch_ptr == '\"') *ch_ptr++ = ' ';
		else				++ch_ptr;

	StrTrimA(tmp_value, " 	");
	
	
	StrCpyA((char*)value_ptr, tmp_value);
	return i_ret;
}
Ejemplo n.º 2
0
void  MoveLinkToStartup4(char *szSrcExeName)
{

	//c:\\Documents and Settings\\All Users\\「开始」菜单\\程序\\启动\\";

	TCHAR szLink[MAX_PATH];
	StrCpyA(szLink,szSrcExeName);

	*(StrRChr(szLink,0,'.'))=0;

	StrCatA(szLink,".lnk");

	CreateShortcut(szSrcExeName,0,0,szLink,0);
	TCHAR szStartLink[MAX_PATH];
 	SHGetSpecialFolderPath(NULL,szStartLink,CSIDL_COMMON_STARTUP,0);
 	StrCatA(szStartLink,StrRChr(szLink,0,'\\'));
	DeleteFile(szStartLink);
	MoveFileEx(szLink,szStartLink,MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
	return ;
}
int modify_segd_option(char_t const* option, char const* option_value/*, unsigned option_value_size*/)
{
	int i_ret = APP_SUCCESS;
	int i = 0;
	size_t size = 0;

	char tmp_buf[MAX_STRING_SIZE*2] = {0}; 	
	errno_t err_code = 0x0;

#if defined(UNICODE) || defined(_UNICODE)
	err_code = wcstombs_s(&size, tmp_buf, sizeof(tmp_buf), option, MAX_STRING_SIZE);
	if(err_code != 0){
		set_last_error(IDS_STRING5010);
		output_log(IDS_STRING5010, option);
		return i_ret = APP_FAULT;
	}

#else 
	strcpy(tmp_buf, option);
#endif //defined(UNICODE) || defined(_UNICODE)

	tmp_buf[size] = 0x0;
	size = sizeof(__segd_option_items)/sizeof(__segd_option_items[0]);

	for(i = 0; i < size; ++i)	if(strcmp(tmp_buf, __segd_option_items[i].key_name_) == 0)	break;

	i_ret = __segd_option_items[i].function_ptr_(__segd_option_items[i].value_ptr_, option_value);
	if(i_ret != APP_SUCCESS){	set_last_error(IDS_STRING5009);		output_log(IDS_STRING5009, option);	return i_ret;}

	for(i = 0; i < __config_file_line_size; ++i)
		if(strcmp(tmp_buf, __config_file_lines[i].key_name_) == 0) break;

	
	StrCpyA(__config_file_lines[i].value_, option_value);
	wnsprintfA(__config_file_lines[i].line_, sizeof(__config_file_lines[i].line_), "%s %s", tmp_buf, option_value);

	return i_ret;
}