首页 \ 问答 \ 无法找到区域设置感知版本的StrSafe函数(StringCbPrintf_lW)(Locale-aware version of StrSafe function (StringCbPrintf_lW) cannot be found)

无法找到区域设置感知版本的StrSafe函数(StringCbPrintf_lW)(Locale-aware version of StrSafe function (StringCbPrintf_lW) cannot be found)

我们(错误地)使用StringCbPrintfW来编写数据库查询,该查询在使用逗号作为小数分隔符的任何语言环境中都失败了。 修复很容易,对吧? 采用语言环境的StringCbPrintf_lW也在strsafe.h中定义。 两者都定义如下:

#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)

所以只需创建语言环境并用StringCbPrintf_lW替换StringCbPrintfW。

Intellisense很高兴,GoToDefinition很高兴,ClCompile不高兴。 我一直在

错误C3861:'StringCbPrintf_lW':找不到标识符

有什么想法有什么不对?


We (mistakenly) used StringCbPrintfW to write a database query which failed miserably on any locale that uses a comma as the decimal separator. Fix is easy enough, right? StringCbPrintf_lW, which takes a locale, is also defined in strsafe.h. Both are defined under:

#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)

so just create the locale and replace StringCbPrintfW with StringCbPrintf_lW.

Intellisense is happy, GoToDefinition is happy, ClCompile is not. I keep getting

error C3861: 'StringCbPrintf_lW': identifier not found

Any ideas what is wrong?


原文:https://stackoverflow.com/questions/37440682
更新时间:2022-11-21 06:11

最满意答案

没有任何地方宣布这一点,我认为这是搞砸我的原因。

等等,它在那里声明 - 在方法的标题中:

static double GetDouble(string prompt)
//                      ^^^^^^^^^^^^^ This is the declaration of prompt

prompt与您看到的其他变量不同,它不是正常变量:它是方法的形式参数

与使用赋值运算符=初始化和明确赋值的常规变量不同,通过调用方法隐式赋值形式参数。 当您调用该方法时,您将向其传递一个带有实际参数的表达式,该参数用作该表达式到形式参数的赋值。 想象一下,在第一次调用之前,将prompt变量分配为"Enter the base: " ,然后在第二次调用之前为其指定"enter the exponent: "以了解调用GetDouble


Nowhere is this declared and I think that's what's messing me up.

Wait, it's declared right there - in the header of the method:

static double GetDouble(string prompt)
//                      ^^^^^^^^^^^^^ This is the declaration of prompt

prompt is different from other variables that you have seen in that it is not a normal variable: it is a formal parameter of a method.

Unlike regular variables which you initialize and assign explicitly with the assignment operator =, formal parameters are assigned implicitly by virtue of calling a method. When you call the method, you pass it an expression with the actual parameter, which acts as an assignment of that expression to the formal parameter. Imagine that the prompt variable is assigned "Enter the base: " before the first call, and then it is assigned "enter the exponent: " before the second call to understand what is going on when you call GetDouble.

相关问答

更多
  • 在我的情况下,我得到这个错误: getParameters失败(空参数) 当我解锁相机后调用getParameters() 。 所以,请在调用camera.unlock()之前调用getParameters() camera.unlock() 。 As +Eddy Talvala mentioned, this happens when the camera is in a bad state. How does the camera get in a bad state? 1) Probably the ...
  • 这是一个非常全面的指导,我认为是必读: 异常和错误处理 - C ++常见问题或C ++常见问题 作为一般的经验法则,当您的程序可以识别出阻止执行的外部问题时,抛出异常。 如果您从服务器接收数据,并且数据无效,则抛出异常。 磁盘空间不足? 抛出异常 宇宙射线阻止您查询数据库? 抛出异常 但是如果您从自己的程序中获取一些无效数据 - 不要抛出异常。 如果你的问题来自你自己的坏代码,最好使用ASSERT来防范它。 需要异常处理来识别程序无法处理的问题,并告诉他们有关用户的问题,因为用户可以处理它们。 但程序中的错 ...
  • 只需检查File.Exists。 如果没有文件,则将该参数设置为DbNull.Value,否则读取该文件 Dim exists = File.Exists(OpenFileDialog8.FileName) ..... cmd.Parameters.Add(New SqlClient.SqlParameter( _ "@AnyOtherDocument", SqlDbType.Image)).Value _ = If(exists, IO.File.ReadAllBytes(Open ...
  • 总之......不。 出于某些原因,请参阅捕获方法状态的问题。 In short ... no. See this question on capturing method state for some reasons.
  • 总的想法是,你将例外渗透到适当的地方来处理它们。 我猜你的导师希望他们能够主要处理。 在这种情况下,我可以猜测,因为你给出了throws子句。 一个简单的经验法则是,如果该方法在throws子句中声明了异常,则不会在该方法中捕获该异常。 所以你写的方法应该没有catch语句。 要做到这一点,你需要改变你的代码: public Catalog loadCatalog(String filename) throws FileNotFoundException, IOExcept ...
  • 根据您所编写的内容,Logic会抛出SpecificException但某些特定信息可能仅在Main可用(如果您有不同的主电源,则可能在语义上不同,即它们可能取决于上下文)。 因此,似乎合理的是, SpecificException仅提供可由Logic提供的上下文信息,然后在Main您可以拥有一个使用SpecificException和特定信息来构建用户消息和(如果需要)日志的辅助类(在文件上,db,等一些可以在以后用于统计或类似事情的信息。 辅助类可以管理不同的Main / SpecificInforma ...
  • 您返回false表示存在异常。 不建议这样做。 重新抛出它 catch(Exception e) { //blah, maybe add some useful text to e throw; } finally { //close up shop Although, look up what using does first incidentally } 然后处理它( catch (Exception e) { MessageBox.Show(("Error: " + e.Message)) ...
  • 没有任何地方宣布这一点,我认为这是搞砸我的原因。 等等,它在那里声明 - 在方法的标题中: static double GetDouble(string prompt) // ^^^^^^^^^^^^^ This is the declaration of prompt prompt与您看到的其他变量不同,它不是正常变量:它是方法的形式参数 。 与使用赋值运算符=初始化和明确赋值的常规变量不同,通过调用方法隐式赋值形式参数。 当您调用该方法时,您将向其传递一个带有 ...
  • 我个人不会在finally添加一个try catch块,然后它可以是一个无穷无尽的链。 通常你不应该在finally有复杂的东西,并且在任何情况下都应该在调用者中捕获意外的异常。 编辑:看起来更接近代码,我不明白为什么最终的代码不应该在try块中。 I personally wouldn't add a try catch block in the finally, then it can be an endless chain. Usually you shouldn't have complicated ...
  • 不要尝试捕获每个方法或层,只有它是合理的。 尝试捕获永远不应该像有条件的那样。 表示层应该永远不会有逻辑。 由于您使用DAL接口,我将创建一个自定义DalException并将其抛出SQLException public int addMethod(ContactClass contactObj) throws DalException { try { return ExecuteSomeSP("SPName", SP_Parameters); } catch(SQL ...

相关文章

更多

最新问答

更多
  • sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
  • 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
  • AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
  • Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
  • 湖北京山哪里有修平板计算机的
  • SimplePie问题(SimplePie Problem)
  • 在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)
  • HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)
  • 为什么我会收到链接错误?(Why do I get a linker error?)
  • 如何正确定义析构函数(How to properly define destructor)
  • 垂直切换菜单打开第3级父级。(Vertical toggle menu 3rd level parent stay opened. jQuery)
  • 类型不匹配 - JavaScript(Type mismatch - JavaScript)
  • 为什么当我将模型传递给我的.Net MVC 4控制器操作时,它坚持在部分更新中使用它?(Why is it that when I pass a Model to my .Net MVC 4 Controller Action it insists on using it in the Partial Update?)
  • 在使用熊猫和statsmodels时拉取变量名称(Pulling variable names when using pandas and statsmodels)
  • 如何开启mysql计划事件
  • 检查数组的总和是否大于最大数,反之亦然javascript(checking if sum of array is greater than max number and vice versa javascript)
  • 使用OpenGL ES绘制轮廓(Drawing Outline with OpenGL ES)
  • java日历格式(java Calendar format)
  • Python PANDAS:将pandas / numpy转换为dask数据框/数组(Python PANDAS: Converting from pandas/numpy to dask dataframe/array)
  • 如何搜索附加在elasticsearch索引中的文档的内容(How to search a content of a document attached in elasticsearch index)
  • LinQ to Entities:做相反的查询(LinQ to Entities: Doing the opposite query)
  • 从ExtJs 4.1商店中删除记录时会触发哪些事件(Which events get fired when a record is removed from ExtJs 4.1 store)
  • 运行javascript后如何截取网页截图[关闭](How to take screenshot of a webpage after running javascript [closed])
  • 如何使用GlassFish打印完整的堆栈跟踪?(How can I print the full stack trace with GlassFish?)
  • 如何获取某个exe应用程序的出站HTTP请求?(how to get the outbound HTTP request of a certain exe application?)
  • 嗨,Android重叠背景片段和膨胀异常(Hi, Android overlapping background fragment and inflate exception)
  • Assimp详细说明typedef(Assimp elaborated type refers to typedef)
  • 初始化继承类中不同对象的列表(initialize list of different objects in inherited class)
  • 使用jquery ajax在gridview行中保存星级评分(Save star rating in a gridview row using jquery ajax)
  • Geoxml3 groundOverlay zIndex(Geoxml3 groundOverlay zIndex)